954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Getting this error:Warning: Invalid argument supplied for foreach() in /home4/thesist

I am getting this error ,can anyone help me :

Warning: Invalid argument supplied for foreach() in /home4/thesisth/public_html/pdfsearchmachine/classes/rss.php on line 14

Here is the rss.php

code

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">          

<?
$search = $_GET["search"];
$replace = " "; $with = "+";
$search = str_replace($replace, $with, $search);

if ($rs = $rss->get("http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&query=originurlextension%3Apdf+$search&adult_ok=1&start=$start")) 
{

}

// Go through the list powered by the search engine listed and get the data from each <item>
$colorCount="0";

   foreach($rs['items'] as $item) 
	{ 

	// Get the title of result

	   $title = $item['title'];

	// Get the description of the result

	   $description = $item['description'];

	// Get the link eg amazon.com

	   $urllink = $item['guid'];

if($colorCount%2==0)
{
$color = ROW1_COLOR;
}
else
{
$color = ROW2_COLOR;
}

include "resulttemplate.php";
$colorCount++;
 echo "\n"; 

} 

	



?>
amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&query=originurlextension%3Apdf+$search&adult_ok=1&start=$start

your above is not returning proper output, there is error on that server


I am using the same URL with another website and it is working..how i can correct that..

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

For php error,
Always put foreach in if condition.

if(count($rs['items'])>0)
{
	foreach($rs['items'] as $item) 
	{ 
		//--- code---
	}
}
else
{
	echo 'There is no items...';
}


And for URL there are some php variables in url like$search.
Check the string generated (output of php code) in the one you have used in another site.

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

For php error, Always put foreach in if condition.

if(count($rs['items'])>0)
{
	foreach($rs['items'] as $item) 
	{ 
		//--- code---
	}
}
else
{
	echo 'There is no items...';
}

And for URL there are some php variables in url like$search. Check the string generated (output of php code) in the one you have used in another site.


Someone told me that maximum number of searches per day by yahoo is only 5000 ,if you want to advance that ,you need to pay..is that true?

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

For php error, Always put foreach in if condition.

if(count($rs['items'])>0)
{
	foreach($rs['items'] as $item) 
	{ 
		//--- code---
	}
}
else
{
	echo 'There is no items...';
}

And for URL there are some php variables in url like$search. Check the string generated (output of php code) in the one you have used in another site.


It is working with that URL ,previuos one ,I did not do any changes,Sometimes it works and sometimes don't ,I don't know why..

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

It might be the api is not responding correctly...this problem exist sometimes due to heavy load or change(updation or modification) in api.....

tomato.pgn
Posting Whiz in Training
262 posts since Mar 2011
Reputation Points: 4
Solved Threads: 32
 

So ,What you think the

http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&query=originurlextension%3Apdf+$search&adult_ok=1&start=$start

this API is temporary blockage or permanent as Yahoo said it is going to stop some of it's services..

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: