HELP ME TO FIX THIS CODE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arisandria2013
Forum Newbie
Posts: 1
Joined: Fri Dec 24, 2010 2:44 am

HELP ME TO FIX THIS CODE

Post by arisandria2013 »

i've PSD SEARCH ENGINE SCRIPT but the script ERROR in search.php
when i tested in XAMPP the script 100% succes but in webhosting ERROR. HELP ME TO FIX THIS CODE PLEASE..

Code: Select all

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

// Go through the list powered by the search engine listed and get the data from each <item>

    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'];

include "Class/resulttemplate.php";

 echo "\n"; 
}
?>
ERROR CODE:

Code: Select all

Warning: Invalid argument supplied for foreach() in /home/vol2/xxxxxx.com/xth_xxxxx/xxxx-xxx.co.cc/htdocs/search.php on line 56
this is link to download PSD SEARCH ENGINE SCRIPT if you want to test it: http://www.uploadhappy.com/files/1TFHZH ... engine.rar

HELP ME TO FIX IT PLEASE.. THANK YOU
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: HELP ME TO FIX THIS CODE

Post by social_experiment »

Foreach() statements need an array to work properly. Is $rs['items'] an array?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: HELP ME TO FIX THIS CODE

Post by califdon »

Just before the foreach line, print out the contents of $rs, using the PHP function print_r($rs). It should print out an array structure. If it does not, you will have to go back to where $rs was created and find out why not.
Post Reply