Kokichi Posted May 13, 2007 Share Posted May 13, 2007 So I have to finish a midterm assignment by tomorrow. I thought my PHP was correct, but apparently it's wrong. Here's the assignment: Create a PHP script which will read in a variable keyword and, with the data contained in that variable, query Amazon for items related to that data, and return those items. This amounts to adding &Keywords= to your standard Amazon query string. Post it on your website as midterm.php I've made the html and the xml file okay, but it's the php file that's giving me trouble. The point of the project is to create a search bar that will reference one of Amazon's items (like books, movies, etc.), then allow the user to type in whatever and search for it. My php file looks like this: #! usr/local/bin/php <html> <head> <title> midterm.php </title> </head> <body> <?php include "data.php"; include "language.php "; $url =" http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=1PRD4ZJ5Q38MD414GS02&Operation=ItemSearch&ResponseGroup=Medium,Request&SearchIndex=Books&BrowseNode=1000&Sort=salesrank&Style=http://www.pic.ucla.edu/~karenyee/homework2.xsl&Keywords= " echo $_REQUEST['keyword']; $query_string = ''; $params = array{ 'mode' => 'dvd', 'sort' => '+salesrank', 'page' => '1', 'type' => 'lite', 'devtag' => '11VJYHGRK99W0JW87Y02', }; foreach ($params as $key => $value) { $query_string .= "$key=" . urlencode($value) . "&"; } $website = "$url$query_string"; $xml = file_get_contents($website); $result = $proxy->BrowseNodeSearchRequest ($params); print_r($result); ?> </body> </html> Does that look like it would work? What's wrong with it? You can check my site at http://www.pic.ucla.edu/~karenyee/ and click on midterm.html to see if it works (it should be working like www.pic.ucla.edu/~sndesai 's one, but it doesn't). Thanks so much!! ~Karen Quote Link to comment Share on other sites More sharing options...
Kokichi Posted May 14, 2007 Author Share Posted May 14, 2007 Shameless bump... :'( Quote Link to comment Share on other sites More sharing options...
john010117 Posted May 14, 2007 Share Posted May 14, 2007 ...and click on midterm.html... Shouldn't it be "midterm.php"? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.