Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Warning: Invalid argument supplied for foreach()
Old 07-27-2010, 12:50 PM Warning: Invalid argument supplied for foreach()
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
I am using a Bing library for search 2.0,
This is my script:
PHP Code:
[LEFT]<?php
require_once '../bingapiphp-1.1/library/BingAPI.php';

$term=$_Request["term"];
$type=$_Request["type"];
$count=$_Request["count"];
$search = new BingAPI('AppID replaced for posting');
$search ->query("'".$term."'");
$search ->setSources("'".$type."'");
$search ->setFormat('json');
$search ->setOptions(
array(
$type.'.Count' => $count
$type.'.Offset' => '0'
'Adult' => 'Moderate'
'Options' => 'EnableHighlighting')
);

$result json_decode($search->getResults());

foreach(
$result->SearchResponse->$type->Results as $item)
{
echo(

<div class='Title'>
$item[Title]</div>
<div class='Description'>
$item[Description]</div>
<div class='Url'><a href='
$item[Url]' target='_blank'>$item[Url]</a></div>
<br>
"
);
}[/
LEFT]
?>
[LEFT][/LEFT]
I am using the library because I got an error in my foreach statement, I get the same error with the library:

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\TickTach\php\search.php on line 25

I have tried replacing $type with a literal and I get the same error, so please do not focus on that... Can anyone tell me what the problem is?
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
View Public Profile
 
 
Register now for full access!
Old 07-27-2010, 12:53 PM Re: Warning: Invalid argument supplied for foreach()
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
Sorry guys, I found it... again... had same problem last night and somehow managed to paste it right back... $_Request should of course be $_REQUEST
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
View Public Profile
 
Closed Thread     « Reply to Warning: Invalid argument supplied for foreach()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16427 seconds with 12 queries