Jump to content

madmatt2006

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://mypcmates.com/

Profile Information

  • Gender
    Male
  • Location
    Melbourne, Australia

madmatt2006's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi All anyone know how to add the amazon add to cart button the this script? script attached, thanks guys [attachment deleted by admin]
  2. update I have added the code from amazonv4.php into pcparts_body.html code below <!-- INCLUDE overall_header.html --> <!-- Your page can be changed to what ever you want displayed in this location. Now if you change the name of the file from something different then yourpage_body.html make sure you also make the chagne in php file as well. --> <div class="c-h-l"><div class="c-h-r"><div class="c-h-c"><div class="c-h-title"><h4>My PC Mates aStore Powered By Amazon</h4> </div></div></div></div> <div class="v-left"><div class="v-right"> <div class="panel"> <div class="inner"><span class="corners-top"><span></span></span> <!-- Then information you wish to add to this page will go between the <div class="content"> and its closing div </div> you do not have to use the paragraphp codes if you do not wish. --> <div class="content"> Your text here test <?php //amazonv4.php //stand-alone PHP example script to use the Amazon Web Services interface //written by Jaap van Ganswijk (JvG) <ganswijk@xs4all.nl> //you can use this version under any version of the GPL (GNU Public License) //20020816/JvG, released under the GNU GPL //... //20090623/JvG, busy adding the signing that Amazon requires from 20090815 //20090804/JvG, refixed the do/du problem for used products (which had gone after going back to an old version) and added the (server) locale functionality to the signed version //20090804/JvG, rewrote the scripts to make the new version (with signing) more like the old version so that the caching would work again but didn't test it yet, this also made show_url work again //20090812/JvG, added the comments for 20090804 and 20090812 and tested the caching and I am going to try to put the script online //20090816/JvG, always use signed request, started adding better time measurement //20090826/JvG, script will now create cache directory itself //20090826/JvG, got simplexml object printing working //20090827/JvG, added printing a simple HTML-header to have utf8 rendered correctly //20090827/JvG, added the $tab variable in all echo statements so all HTML is indented properly //20090827/JvG, removed a lot of old outdated messages from this list //20091105/JvG, separated the AWS requesting part to aws.php //Thanks for all the questions, improvement tips and help! //Feel free to send more feedback to me at ganswijk@xs4all.nl! //Please mention AWS or Amazon in the subject line to avoid my spamfilters error_reporting(error_reporting()&~E_NOTICE); //this prevents a lot of warnings on a Windows server, but you can comment-out this line for debugging $Amicrotime['total'][0]=getmicrotime(); //time at start of total process //send html-header so utf8's are correctly shown echo "<html>\n"; echo " <head>\n"; echo " <meta **********='content-Type' content='text/html; charset=utf-8' />\n"; echo " </head>\n"; echo " <body>\n"; $tab=' '; //tab how much? if (!defined($jaap)) $jaap=$false; //($_SERVER['PHP_SELF']=='/jaap/php/amazon/amazonv4.php' or $_SERVER['PHP_SELF']=='/jaap/php_linux/amazon/amazonv4.php'); //I use this flag to develop new things for the script on my local PC. $jb=false; //this is a test for someone, please change it to false if it isn't already //Set these to correspond with your site. //This will determine the first results that the user will see. //The user can overrule them using the search form. $Adefault=array( 'language' =>'en', //what language to render the page in 'locale' =>'us', //which server's products? available: ca,de,fr,jp,uk,us //'mode' =>'books', //what product category? 'page' =>1, //first page to show (we are counting from 1 not 0) //'search' =>'Machiavelli', //what to search for? 'operation' =>'ItemSearch', //what to do? 'searchindex' =>'Books', //what product category for search? 'searchparameter' =>'Author', //what kind of search? 'searchparameterdata'=>'Machiavelli', //what to search for? //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true' 'jaap' =>false, //my own debugflag to test new things 'show_array' =>false, //debug: show complete incoming array? You can use this to see what other information Amazon is sending 'show_url' =>false, //debug: show XML request url to be send to Amazon? 'show_xml' =>false, //debug: show incoming XML code from Amazon? ); //change the debug options to true if you want to activate them or call the script with '?show_array=true' to see what actual information you're getting from Amazon and how little my standard script is actually showing of it require_once "data.php"; //static data about Amazon (servers, search fields) v3- require_once "data_v4.php"; //static data about Amazon (servers, search fields) v4+ require_once "language.php"; //translate the output to the prefered language of the user require_once "aws.php"; //see: http://mierendo.com/software/aws_signed_query/, please note that I'm using an slightly adapted version of the script: I do my own XML-interpreting //20090624: the following isn't relevant anymore it seems, 20091122: yes it is! $Aassociates_id=array( 'de'=>'chipdir00' , // <-- replace with your amazon.de associate ID, or leave it as it is 'fr'=>'chipdir010', // <-- replace with your amazon.fr associate ID, or leave it as it is 'jp'=>'INVALID' , // <-- replace with your amazon.co.jp associate ID, or leave it as it is 'uk'=>'chipdir03' , // <-- replace with your amazon.co.uk associate ID, or leave it as it is 'us'=>'chipdir' , // <-- replace with your amazon.com associate ID ); //If you haven't gotten your own associate ID yet, get it from: //http://associates.amazon.com/exec/panama/associates/apply // //Normally you will want to start selling books via Amazon.com only, //just to see if it works and pays well (which it normally doesn't). // //You can save yourself a lot of trouble by not applying for an associate ID //at the other local Amazon sites yet, but leaving mine in for the time being //and perhaps I'll make a few pounds, euro's and/or yen. As soon as I would //receive a noticable amount of cash I'll track you down an will warn you //to get your own ID's there. // //please note that all those local Amazons send out all of their communications //in their local languages, so French, German and Japanese for example and //that you first have to earn enough money per branch before you get paid. //And the Japanese branch only seems to pay in gift-certificates, so you'd //have to buy Japanese books for example. // //if you want to disable any of the foreign branches, please do so in the //file data.php, but please consider that we're living in an ever better //connected world and sometime later you might want to add them again //if only as a service to your visitors. //other flags: //this doesn't seem to be relevant anymore: //$f_rich=true; //when set to true this will convert the URL so you'll get 7.5% on qualifying books instead of 5%. It doesn't work yet outside of the USA. //change it to false when you prefer to get only 5% ;-) //see http://forums.prospero.com/n/mb/message.asp?webtag=am-assosdev&msg=6.1&ctx=0, or search the forum for 'nosim' //This is only helpful for certain books //correction: keep this option set to true, to prevent the showing of Amazon's annoying distraction pages. //20080530: i don't know if this is still relevant for version 4 $f_user_search=true; //add a user search form and allow user searches? //============================================================================= //==You don't have to change anything below this line to start earning money.== //============================================================================= if ($jaap) { print_array($_GET,$tab); } //what are the user's prefered languages? $Ahttp_lang=split(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); if ($jaap) { print_array($Ahttp_lang,$tab); } //try to find the visitor's prefered language, this is still experimental foreach ($Ahttp_lang as $i=>$d) { if ($Axl[$l=substr($d,0,2)]) { $pref_lang=$l; break; } } if (isset($pref_lang)) { $Adefault['language']=$pref_lang; if ($jaap) { echo $tab."prefered available language='$pref_lang'<br />\n"; } } //for all parameters see if the user has overruled it or use the default foreach ($Adefault as $i=>$d) { $$i=isset($_GET[$i])?$_GET[$i]:$d; if ($jaap) echo $tab."$i = '".$$i."'<br />\n"; } //this is a test for someone: if ($jb) { $operation ='SellerListingSearch'; $show_array=1; } //use which servers? //$norserver=$Aserver[$locale]['nor']; //$xmlserver=$Aserver[$locale]['xml']; //20090817: this is no longer used it seems: //$dev_token='D2WMCOIPS9D14E'; //you can replace this with your own developer token after you have changed the script a lot //get one from http://associates.amazon.com/exec/panama/associates/join/developer/application.html //see: //http://forums.prospero.com/n/mb/message.asp?webtag=am-assocdevxml&msg=378.1&ctx=0 //this is the data that is used to form the request for AWS //this is the part that is search specific if ($jb) { //this is a test for someone $parameters=array( 'Operation' =>$operation , 'SellerId' =>'A23I0F0MWQH94Z' , // 'Keywords' =>urlencode($search) , // 'SearchIndex' =>$searchindex , //Books for example. // "$searchparameter"=>$searchparameterdata , 'ItemPage' =>$page , //which page? // 'Service' =>'AWSECommerceService' , //this makes it version 4 // 'SubscriptionId' =>$subscriptionid , //is this correct? // 'AWSAccessKeyId' =>$awsaccesskeyid , //is this correct? 'AssociateTag' =>$Aassociates_id[$locale], // 'ResponseGroup' =>'Medium' , //Small, Medium or Large 'ResponseGroup' =>'SellerListing' , //Small, Medium, Large or SellerListing ); } else { $parameters=array( 'Operation' =>$operation , 'Keywords' =>urlencode($search) , 'SearchIndex' =>$searchindex , //Books for example. "$searchparameter"=>$searchparameterdata , 'ItemPage' =>$page , //which page? // 'Service' =>'AWSECommerceService' , //this makes it version 4 // 'SubscriptionId' =>$subscriptionid , //is this correct? // 'AWSAccessKeyId' =>$awsaccesskeyid , //is this correct? 'AssociateTag' =>$Aassociates_id[$locale], 'ResponseGroup' =>'Medium' , //Small, Medium, Large or SellerListing ); } $A=aws_request($parameters); //do the AWS request via cache and decode the XML //debug: if ($jaap) { echo $tab."<hr />\n"; echo $tab."<pre>\n"; print_r ($A); echo $tab."</pre>\n"; //echo $tab."<hr />\n"; //echo $tab."<pre>\n"; //var_dump ($A); //echo $tab."</pre>\n"; //echo $tab."<hr />\n"; //echo $tab."<pre>\n"; //var_export ($A); //echo $tab."</pre>\n"; echo $tab."<hr />\n"; print_array($A); echo $tab."<hr />\n"; } $Amicrotime['XML'][1]=getmicrotime(); //time after XML decoding //debug: show the array or object //you can easily use this debugging tool by adding '&show_array=1' to the URL of this script if ($show_array) { //show the array for debugging? print_array($A,$tab); //show the complete array } //show the stuff $Amicrotime['show'][0]=getmicrotime(); //time before showing stuff echo $tab."<h2>".xu('searching for')." '$searchparameterdata'</h2>\n"; //you can change the h2's to h1's //20090827/old code: //if ($e=$error_msg) { // switch ($Aerror[$e]) { // case 'print': // echo $tab."$e<br />\n"; // break; // default: // echo $tab.xu('Amazon returned the error').': '.$e."<br />\n"; // echo $tab."<br />\n"; // echo $tab.xu('please add this error message to the '). // "<a href='http://www.chipdir.nl/amazon/errorlist.php?do=add&da=".urlencode($e)."&ur=".$file."'>". // xl('database')."</a>.<br />\n"; // break; // } //} //$jaap=true; //actually show the products: //echo $A->Items->Request->IsValid; if (isset($A->Error)) { $c=$A->Error->Code; $e=$A->Error->Message; echo $tab."Amazon error: $c: $e<br />\n"; } else if ($A->Items->Request->IsValid!='True') { $c=$A->Items->Request->Errors->Error->Code; $e=$A->Items->Request->Errors->Error->Message; echo $tab."Amazon error: $c: $e<br />\n"; } else { print_products($A,$tab); } //print all the products function print_products($A,$tab='') { global $jaap; global $language; global $locale; global $operation; global $page; global $search; global $searchparameter; global $searchparameterdata; switch ($operation) { case 'SellerListingSearch': die("sorry but SellerListingSearch doesn't work yet"); $items =$A['SellerListingSearchResponse']['SellerListings']; $subnode='SellerListing'; break; default: // $items=$A['ItemSearchResponse']['Items']; //old // $subnode='Item'; // break; if ($jaap) { echo $tab."in print_products():<br />\n"; echo $tab."A:<br />\n"; print_array($A,$tab=''); } $items =$A ->Items; // $items_sub=$items->Item; $aitems=(array)$items; //it is very strange that this and the next line works and not the outcommented line before this one $items_sub=$aitems['Item']; if ($jaap) { echo $tab."items:<br />\n"; echo $tab."<pre>\n"; print_r($items); echo $tab."</pre>\n"; echo $tab."items:<br />\n"; print_array($items,$tab=''); echo $tab."items->Item:<br />\n"; echo $tab."<pre>\n"; print_r($items->Item); echo $tab."</pre>\n"; echo $tab."items->Item:<br />\n"; print_array($items->Item,$tab=''); echo $tab."items_sub:<br />\n"; echo $tab."<pre>\n"; print_r($items_sub); echo $tab."</pre>\n"; echo $tab."items_sub:<br />\n"; print_array($items_sub,$tab=''); } break; } $npro=$items->TotalResults; $npag=$items->TotalPages; echo $tab."<b>".xu('number of products').": $npro</b><br />\n"; echo $tab."<b>".xu('page').' '.($page).' '.xl('of').' '.((int)$npag)."</b><br />\n"; echo $tab."<p />\n"; echo $tab."<table border='1'>\n"; echo $tab." <tbody>\n"; if (is_array($items_sub) and $items_sub[0]) { foreach ($items_sub as $i=>$E) { print_product($E,$tab.' '); } } else { print_product($D,$tab.' '); } echo $tab." </tbody>\n"; echo $tab."</table>\n"; //provide links to previous and next page if ($npag>1) { //echo $tab."<hr>\n"; echo $tab.xu('page:')."\n"; echo $tab.make_link_to_page(1,1)."\n"; echo $tab.make_link_to_page(2,2)."\n"; if ($page>=2) { echo $tab.make_link_to_page($page-1,'<')."\n"; } if ($page<$npag) { echo $tab.make_link_to_page($page+1,'>')."\n"; } echo $tab.make_link_to_page($npag,$npag)."\n"; } } //print one Amazon product //version 4 function print_product($E,$tab) { //global $Aassociates_id; //global $dev_token; //global $f_rich; //do you want 15% or 5%? (only for discounted books), 20090624: I don't know if this is still relevant global $jaap; global $locale; //global $norserver; if ($E) { if ($jaap) echo $tab."print_product()<br />\n"; $url=$E->DetailPageURL; if ($jaap) echo $tab."url=$url<br />\n"; $E2A=(array)$E; $url=$E2A['DetailPageURL']; if ($jaap) echo $tab."url=$url<br />\n"; if ($jaap) print_array($E2A); //print_array($E); //rebuild the URL if you want 15% instead of 5%: //20090804/wjvg: changed this: // $url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/ref=nosim/'.$Aassociates_id[$locale].'?dev-t='.$dev_token:$E['url']; //$url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/'.$Aassociates_id[$locale]:$E['url']; echo $tab. "<tr>\n"; echo $tab. " <td align='center'>\n"; if ($d=$E->MediumImage) { $iu=$d->URL; $ih=$d->Height; $iw=$d->Width; echo $tab. " <a href='$url'><img src='$iu' width='$iw' height='$ih' border='0'></a>\n"; } echo $tab. " </td>\n"; echo $tab. " <td align='center'>\n"; if ($d=$E->ItemAttributes->Title) { echo $tab. " <a href='$url'>$d</a><br />\n"; } if (is_array($dd=$E->ItemAttributes->Author)) { echo $tab. " ".xl('by').": "; foreach ($dd as $i=>$d) { if ($i) echo ', '; //echo $tab."<a href="<b>$d</b>"; echo "<b>$d</b>"; } echo "<br />\n"; } else if ($d=$dd) { echo $tab. " ".xl('by').": <b>$d</b><br />\n"; } $dm=$E->ItemAttributes->Publisher; $dr=$E->ItemAttributes->PublicationDate; if ($dm or $dr) { echo $tab. " "; if ($dm) { echo xl('publisher').": <b>$dm</b>"; } if ($dm and $dr) echo ', '; if ($dr) { echo xl('published').": <b>$dr</b>"; } echo "<br />\n"; } if ($asin=$E->ASIN) { echo $tab. " ASIN: <b>$asin</b><br />\n"; } if ($ean=$E->ItemAttributes->EAN) { echo $tab." EAN: <b>$ean</b><br />\n"; } //$da=$E->Reviews->AvgCustomerRating; //not in Medium Set? $da=false; //don't show $ds=$E->SalesRank; if ($da or $ds) { echo $tab. " "; if ($ds) echo xl('sales rank').": <b>$ds</b>"; if ($da and $ds) echo ", "; if ($da) echo $tab.xl('customer rating').": <b>".(($da-1)*25)."%</b>"; echo "<br />\n"; } $do=$E->OfferSummary->LowestNewPrice ->FormattedPrice; $du=$E->OfferSummary->LowestUsedPrice->FormattedPrice; if ($do or $du) { echo $tab. " ".xl('price').": "; if ($do) echo "<b>$do</b> (".xl('new').")"; if ($do and $du) echo ", "; if ($du) echo "<b>$du</b> (".xl('used').")"; echo "<br />\n"; } echo $tab. " </td>\n"; if ($EditorialReviews=$E->EditorialReviews and $EditorialReview=$EditorialReviews->EditorialReview and $Content=$EditorialReview->Content) { echo $tab. " <td align='center'>\n"; echo $tab. " $Content\n"; echo $tab. " </td>\n"; } echo $tab. "</tr>\n"; } } //make link to other page (next, previous etc.) function make_link_to_page($page,$s) { global $language; global $locale; global $search; global $searchindex; global $searchparameter; global $searchparameterdata; return "<a href='?". 'language' .'='.$language .'&'. 'locale' .'='.$locale .'&'. 'page' .'='.$page .'&'. 'searchindex' .'='.$searchindex .'&'. 'searchparameter' .'='.$searchparameter .'&'. 'searchparameterdata'.'='.urlencode($searchparameterdata).'&'. "'>".xu($s)."</a>"; } //print an array or object //(for debugging) function print_array($A,$tab='') { if (is_object($A)) { echo $tab."object:<br >\n"; print_array((array)$A,$tab); } else if (is_array($A)) { // print_r($A); echo $tab."<table border='1'>\n"; echo $tab." <tbody>\n"; // echo $tab." COUNT=".count($A)."\n"; // if (is_object($A)) { // echo $tab." COUNT=".count($A)." - ".$A['0']."\n"; // } foreach ($A as $i=>$d) { echo $tab." <tr>\n"; echo $tab." <td valign='top'>$i</td>\n"; // print_r($d); if (is_string($d)) { // echo $tab." STRING\n"; // print_r($d); // echo $tab." <td><pre>".htmlentities($d)."</pre></td>\n"; echo $tab." <td>".htmlentities($d)."</td>\n"; } else if (is_array($d)) { // echo $tab." ARRAY or OBJECT\n"; echo $tab." <td>\n"; print_array($d,$tab.' '); echo $tab." </td>\n"; } else if (is_object($d)) { // echo $tab." ARRAY or OBJECT\n"; echo $tab." <td>object:\n"; print_array((array)$d,$tab.' '); echo $tab." </td>\n"; } else { // echo $tab." ELSE\n"; // print_r($d); // echo $tab." <td><pre>".htmlentities($d)."</pre></td>\n"; echo $tab." <td>".htmlentities($d)."</td>\n"; } echo $tab." </tr>\n"; } echo $tab." </tbody>\n"; echo $tab."</table>\n"; } else { echo $tab."warning: not-an-array-or-object given to print_array()<br />\n"; } } function getmicrotime() { list($us,$s)=explode(' ',microtime()); return (float)$us+(float)$s; } if ($f_user_search) { //the next section adds a search box for the users echo $tab. "<hr />\n"; echo $tab. "<form method='get' action='?'>\n"; //echo $tab." <input type='hidden' name='language' value='$language' />\n"; //echo $tab." <input type='hidden' name='locale' value='$locale' />\n"; //echo $tab." <input type='text' name='ty'>Search type</input><br />\n"; echo $tab. " <table>\n"; echo $tab. " <tbody>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('language for page:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='language'>\n"; foreach ($Alanguage as $i=>$d) { echo $tab." <option value='$i'".($i==$language?" selected='true'":"").">".xu($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('which server:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='locale'>\n"; foreach ($Alocale as $i=>$d) { echo $tab." <option value='$i'".($i==$locale?" selected='true'":"").">".xl($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('operation:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='operation'>\n"; foreach ($Aoperation as $i=>$d) { echo $tab." <option value='$i'".($i==$operation?" selected='true'":"").">".xu($i)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('product category:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='searchindex'>\n"; foreach ($Asearchindex as $i=>$d) { //uk and jp not ready yet? 20080730: must be adjusted to the locale again echo $tab." <option value='$d'".($d==$searchindex?" selected='true'":"").">".xl($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('search parameter:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='searchparameter'>\n"; foreach ($Aoperation['ItemSearch']['RequiredParameters']['SearchIndex'] as $i=>$d) { echo $tab." <option value='$d'".($d==$searchparameter?" selected='true'":"").">".xu($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('search string:')."</td>\n"; echo $tab. " <td><input type='text' name='searchparameterdata' value='$searchparameterdata' /></td>\n"; echo $tab. " </tr>\n"; echo $tab. " </tbody>\n"; echo $tab. " </table>\n"; echo $tab. " <input type='submit' value='Search' />\n"; echo $tab. "</form>\n"; //end of the search box section } //phpinfo(); $Amicrotime['show' ][1]=getmicrotime(); //time after showing $Amicrotime['total'][1]=getmicrotime(); //time at end //The next part is to show if the script isn't overburdoning your server. (The time waiting for Amazon isn't burdoning your server). You can remove the next part if you like: echo $tab."<hr />\n"; //echo("Time used for time-consuming parts:<br />\n"); echo $tab."Time used:<br />\n"; foreach ($Amicrotime as $i=>$d) { //if ($d[1]>$d[0]) { printf($tab."- %.2f s %s<br />\n",$d[1]-$d[0],$i); //} } //20091129/wjvg: you may remove these lines or move them to an about section of your site: echo $tab."<hr />\n"; echo $tab."This script is GPL'ed and can be downloaded from <a href='http://www.chipdir.nl/amazon/'>this page</a>.<br />\n"; echo " </body>\n"; echo "</html>\n"; ?> </div> <span class="corners-bottom"><span></span></span></div> </div> </div></div> <div class="c-f-l"><div class="c-f-r"><div class="c-f-c"></div></div></div> <!-- INCLUDE jumpbox.html --> <!-- INCLUDE overall_footer.html --> the page loads but none of the amazonv4.php stuff is showing, so I had a bit of a look around the net and came across this Run PHP from HTML - .html as .php - Execute PHP in .html do you think this is why it might not be showing?
  3. ok I found a better script and got it working I really need some help with this being fairly new at in and chucking myself in the deep end at the moment I'm trying to get this page http://mypcmates.com/aws/amazonv4.php which runs a scripts, this is the code from that page <?php //amazonv4.php //stand-alone PHP example script to use the Amazon Web Services interface //written by Jaap van Ganswijk (JvG) <ganswijk@xs4all.nl> //you can use this version under any version of the GPL (GNU Public License) //20020816/JvG, released under the GNU GPL //... //20090623/JvG, busy adding the signing that Amazon requires from 20090815 //20090804/JvG, refixed the do/du problem for used products (which had gone after going back to an old version) and added the (server) locale functionality to the signed version //20090804/JvG, rewrote the scripts to make the new version (with signing) more like the old version so that the caching would work again but didn't test it yet, this also made show_url work again //20090812/JvG, added the comments for 20090804 and 20090812 and tested the caching and I am going to try to put the script online //20090816/JvG, always use signed request, started adding better time measurement //20090826/JvG, script will now create cache directory itself //20090826/JvG, got simplexml object printing working //20090827/JvG, added printing a simple HTML-header to have utf8 rendered correctly //20090827/JvG, added the $tab variable in all echo statements so all HTML is indented properly //20090827/JvG, removed a lot of old outdated messages from this list //20091105/JvG, separated the AWS requesting part to aws.php //Thanks for all the questions, improvement tips and help! //Feel free to send more feedback to me at ganswijk@xs4all.nl! //Please mention AWS or Amazon in the subject line to avoid my spamfilters error_reporting(error_reporting()&~E_NOTICE); //this prevents a lot of warnings on a Windows server, but you can comment-out this line for debugging $Amicrotime['total'][0]=getmicrotime(); //time at start of total process //send html-header so utf8's are correctly shown echo "<html>\n"; echo " <head>\n"; echo " <meta **********='content-Type' content='text/html; charset=utf-8' />\n"; echo " </head>\n"; echo " <body>\n"; $tab=' '; //tab how much? if (!defined($jaap)) $jaap=$false; //($_SERVER['PHP_SELF']=='/jaap/php/amazon/amazonv4.php' or $_SERVER['PHP_SELF']=='/jaap/php_linux/amazon/amazonv4.php'); //I use this flag to develop new things for the script on my local PC. $jb=false; //this is a test for someone, please change it to false if it isn't already //Set these to correspond with your site. //This will determine the first results that the user will see. //The user can overrule them using the search form. $Adefault=array( 'language' =>'en', //what language to render the page in 'locale' =>'us', //which server's products? available: ca,de,fr,jp,uk,us //'mode' =>'books', //what product category? 'page' =>1, //first page to show (we are counting from 1 not 0) //'search' =>'Machiavelli', //what to search for? 'operation' =>'ItemSearch', //what to do? 'searchindex' =>'Books', //what product category for search? 'searchparameter' =>'Author', //what kind of search? 'searchparameterdata'=>'Machiavelli', //what to search for? //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true' 'jaap' =>false, //my own debugflag to test new things 'show_array' =>false, //debug: show complete incoming array? You can use this to see what other information Amazon is sending 'show_url' =>false, //debug: show XML request url to be send to Amazon? 'show_xml' =>false, //debug: show incoming XML code from Amazon? ); //change the debug options to true if you want to activate them or call the script with '?show_array=true' to see what actual information you're getting from Amazon and how little my standard script is actually showing of it require_once "data.php"; //static data about Amazon (servers, search fields) v3- require_once "data_v4.php"; //static data about Amazon (servers, search fields) v4+ require_once "language.php"; //translate the output to the prefered language of the user require_once "aws.php"; //see: http://mierendo.com/software/aws_signed_query/, please note that I'm using an slightly adapted version of the script: I do my own XML-interpreting //20090624: the following isn't relevant anymore it seems, 20091122: yes it is! $Aassociates_id=array( 'de'=>'chipdir00' , // <-- replace with your amazon.de associate ID, or leave it as it is 'fr'=>'chipdir010', // <-- replace with your amazon.fr associate ID, or leave it as it is 'jp'=>'INVALID' , // <-- replace with your amazon.co.jp associate ID, or leave it as it is 'uk'=>'chipdir03' , // <-- replace with your amazon.co.uk associate ID, or leave it as it is 'us'=>'chipdir' , // <-- replace with your amazon.com associate ID ); //If you haven't gotten your own associate ID yet, get it from: //http://associates.amazon.com/exec/panama/associates/apply // //Normally you will want to start selling books via Amazon.com only, //just to see if it works and pays well (which it normally doesn't). // //You can save yourself a lot of trouble by not applying for an associate ID //at the other local Amazon sites yet, but leaving mine in for the time being //and perhaps I'll make a few pounds, euro's and/or yen. As soon as I would //receive a noticable amount of cash I'll track you down an will warn you //to get your own ID's there. // //please note that all those local Amazons send out all of their communications //in their local languages, so French, German and Japanese for example and //that you first have to earn enough money per branch before you get paid. //And the Japanese branch only seems to pay in gift-certificates, so you'd //have to buy Japanese books for example. // //if you want to disable any of the foreign branches, please do so in the //file data.php, but please consider that we're living in an ever better //connected world and sometime later you might want to add them again //if only as a service to your visitors. //other flags: //this doesn't seem to be relevant anymore: //$f_rich=true; //when set to true this will convert the URL so you'll get 7.5% on qualifying books instead of 5%. It doesn't work yet outside of the USA. //change it to false when you prefer to get only 5% ;-) //see http://forums.prospero.com/n/mb/message.asp?webtag=am-assosdev&msg=6.1&ctx=0, or search the forum for 'nosim' //This is only helpful for certain books //correction: keep this option set to true, to prevent the showing of Amazon's annoying distraction pages. //20080530: i don't know if this is still relevant for version 4 $f_user_search=true; //add a user search form and allow user searches? //============================================================================= //==You don't have to change anything below this line to start earning money.== //============================================================================= if ($jaap) { print_array($_GET,$tab); } //what are the user's prefered languages? $Ahttp_lang=split(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); if ($jaap) { print_array($Ahttp_lang,$tab); } //try to find the visitor's prefered language, this is still experimental foreach ($Ahttp_lang as $i=>$d) { if ($Axl[$l=substr($d,0,2)]) { $pref_lang=$l; break; } } if (isset($pref_lang)) { $Adefault['language']=$pref_lang; if ($jaap) { echo $tab."prefered available language='$pref_lang'<br />\n"; } } //for all parameters see if the user has overruled it or use the default foreach ($Adefault as $i=>$d) { $$i=isset($_GET[$i])?$_GET[$i]:$d; if ($jaap) echo $tab."$i = '".$$i."'<br />\n"; } //this is a test for someone: if ($jb) { $operation ='SellerListingSearch'; $show_array=1; } //use which servers? //$norserver=$Aserver[$locale]['nor']; //$xmlserver=$Aserver[$locale]['xml']; //20090817: this is no longer used it seems: //$dev_token='D2WMCOIPS9D14E'; //you can replace this with your own developer token after you have changed the script a lot //get one from http://associates.amazon.com/exec/panama/associates/join/developer/application.html //see: //http://forums.prospero.com/n/mb/message.asp?webtag=am-assocdevxml&msg=378.1&ctx=0 //this is the data that is used to form the request for AWS //this is the part that is search specific if ($jb) { //this is a test for someone $parameters=array( 'Operation' =>$operation , 'SellerId' =>'A23I0F0MWQH94Z' , // 'Keywords' =>urlencode($search) , // 'SearchIndex' =>$searchindex , //Books for example. // "$searchparameter"=>$searchparameterdata , 'ItemPage' =>$page , //which page? // 'Service' =>'AWSECommerceService' , //this makes it version 4 // 'SubscriptionId' =>$subscriptionid , //is this correct? // 'AWSAccessKeyId' =>$awsaccesskeyid , //is this correct? 'AssociateTag' =>$Aassociates_id[$locale], // 'ResponseGroup' =>'Medium' , //Small, Medium or Large 'ResponseGroup' =>'SellerListing' , //Small, Medium, Large or SellerListing ); } else { $parameters=array( 'Operation' =>$operation , 'Keywords' =>urlencode($search) , 'SearchIndex' =>$searchindex , //Books for example. "$searchparameter"=>$searchparameterdata , 'ItemPage' =>$page , //which page? // 'Service' =>'AWSECommerceService' , //this makes it version 4 // 'SubscriptionId' =>$subscriptionid , //is this correct? // 'AWSAccessKeyId' =>$awsaccesskeyid , //is this correct? 'AssociateTag' =>$Aassociates_id[$locale], 'ResponseGroup' =>'Medium' , //Small, Medium, Large or SellerListing ); } $A=aws_request($parameters); //do the AWS request via cache and decode the XML //debug: if ($jaap) { echo $tab."<hr />\n"; echo $tab."<pre>\n"; print_r ($A); echo $tab."</pre>\n"; //echo $tab."<hr />\n"; //echo $tab."<pre>\n"; //var_dump ($A); //echo $tab."</pre>\n"; //echo $tab."<hr />\n"; //echo $tab."<pre>\n"; //var_export ($A); //echo $tab."</pre>\n"; echo $tab."<hr />\n"; print_array($A); echo $tab."<hr />\n"; } $Amicrotime['XML'][1]=getmicrotime(); //time after XML decoding //debug: show the array or object //you can easily use this debugging tool by adding '&show_array=1' to the URL of this script if ($show_array) { //show the array for debugging? print_array($A,$tab); //show the complete array } //show the stuff $Amicrotime['show'][0]=getmicrotime(); //time before showing stuff echo $tab."<h2>".xu('searching for')." '$searchparameterdata'</h2>\n"; //you can change the h2's to h1's //20090827/old code: //if ($e=$error_msg) { // switch ($Aerror[$e]) { // case 'print': // echo $tab."$e<br />\n"; // break; // default: // echo $tab.xu('Amazon returned the error').': '.$e."<br />\n"; // echo $tab."<br />\n"; // echo $tab.xu('please add this error message to the '). // "<a href='http://www.chipdir.nl/amazon/errorlist.php?do=add&da=".urlencode($e)."&ur=".$file."'>". // xl('database')."</a>.<br />\n"; // break; // } //} //$jaap=true; //actually show the products: //echo $A->Items->Request->IsValid; if (isset($A->Error)) { $c=$A->Error->Code; $e=$A->Error->Message; echo $tab."Amazon error: $c: $e<br />\n"; } else if ($A->Items->Request->IsValid!='True') { $c=$A->Items->Request->Errors->Error->Code; $e=$A->Items->Request->Errors->Error->Message; echo $tab."Amazon error: $c: $e<br />\n"; } else { print_products($A,$tab); } //print all the products function print_products($A,$tab='') { global $jaap; global $language; global $locale; global $operation; global $page; global $search; global $searchparameter; global $searchparameterdata; switch ($operation) { case 'SellerListingSearch': die("sorry but SellerListingSearch doesn't work yet"); $items =$A['SellerListingSearchResponse']['SellerListings']; $subnode='SellerListing'; break; default: // $items=$A['ItemSearchResponse']['Items']; //old // $subnode='Item'; // break; if ($jaap) { echo $tab."in print_products():<br />\n"; echo $tab."A:<br />\n"; print_array($A,$tab=''); } $items =$A ->Items; // $items_sub=$items->Item; $aitems=(array)$items; //it is very strange that this and the next line works and not the outcommented line before this one $items_sub=$aitems['Item']; if ($jaap) { echo $tab."items:<br />\n"; echo $tab."<pre>\n"; print_r($items); echo $tab."</pre>\n"; echo $tab."items:<br />\n"; print_array($items,$tab=''); echo $tab."items->Item:<br />\n"; echo $tab."<pre>\n"; print_r($items->Item); echo $tab."</pre>\n"; echo $tab."items->Item:<br />\n"; print_array($items->Item,$tab=''); echo $tab."items_sub:<br />\n"; echo $tab."<pre>\n"; print_r($items_sub); echo $tab."</pre>\n"; echo $tab."items_sub:<br />\n"; print_array($items_sub,$tab=''); } break; } $npro=$items->TotalResults; $npag=$items->TotalPages; echo $tab."<b>".xu('number of products').": $npro</b><br />\n"; echo $tab."<b>".xu('page').' '.($page).' '.xl('of').' '.((int)$npag)."</b><br />\n"; echo $tab."<p />\n"; echo $tab."<table border='1'>\n"; echo $tab." <tbody>\n"; if (is_array($items_sub) and $items_sub[0]) { foreach ($items_sub as $i=>$E) { print_product($E,$tab.' '); } } else { print_product($D,$tab.' '); } echo $tab." </tbody>\n"; echo $tab."</table>\n"; //provide links to previous and next page if ($npag>1) { //echo $tab."<hr>\n"; echo $tab.xu('page:')."\n"; echo $tab.make_link_to_page(1,1)."\n"; echo $tab.make_link_to_page(2,2)."\n"; if ($page>=2) { echo $tab.make_link_to_page($page-1,'<')."\n"; } if ($page<$npag) { echo $tab.make_link_to_page($page+1,'>')."\n"; } echo $tab.make_link_to_page($npag,$npag)."\n"; } } //print one Amazon product //version 4 function print_product($E,$tab) { //global $Aassociates_id; //global $dev_token; //global $f_rich; //do you want 15% or 5%? (only for discounted books), 20090624: I don't know if this is still relevant global $jaap; global $locale; //global $norserver; if ($E) { if ($jaap) echo $tab."print_product()<br />\n"; $url=$E->DetailPageURL; if ($jaap) echo $tab."url=$url<br />\n"; $E2A=(array)$E; $url=$E2A['DetailPageURL']; if ($jaap) echo $tab."url=$url<br />\n"; if ($jaap) print_array($E2A); //print_array($E); //rebuild the URL if you want 15% instead of 5%: //20090804/wjvg: changed this: // $url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/ref=nosim/'.$Aassociates_id[$locale].'?dev-t='.$dev_token:$E['url']; //$url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/'.$Aassociates_id[$locale]:$E['url']; echo $tab. "<tr>\n"; echo $tab. " <td align='center'>\n"; if ($d=$E->MediumImage) { $iu=$d->URL; $ih=$d->Height; $iw=$d->Width; echo $tab. " <a href='$url'><img src='$iu' width='$iw' height='$ih' border='0'></a>\n"; } echo $tab. " </td>\n"; echo $tab. " <td align='center'>\n"; if ($d=$E->ItemAttributes->Title) { echo $tab. " <a href='$url'>$d</a><br />\n"; } if (is_array($dd=$E->ItemAttributes->Author)) { echo $tab. " ".xl('by').": "; foreach ($dd as $i=>$d) { if ($i) echo ', '; //echo $tab."<a href="<b>$d</b>"; echo "<b>$d</b>"; } echo "<br />\n"; } else if ($d=$dd) { echo $tab. " ".xl('by').": <b>$d</b><br />\n"; } $dm=$E->ItemAttributes->Publisher; $dr=$E->ItemAttributes->PublicationDate; if ($dm or $dr) { echo $tab. " "; if ($dm) { echo xl('publisher').": <b>$dm</b>"; } if ($dm and $dr) echo ', '; if ($dr) { echo xl('published').": <b>$dr</b>"; } echo "<br />\n"; } if ($asin=$E->ASIN) { echo $tab. " ASIN: <b>$asin</b><br />\n"; } if ($ean=$E->ItemAttributes->EAN) { echo $tab." EAN: <b>$ean</b><br />\n"; } //$da=$E->Reviews->AvgCustomerRating; //not in Medium Set? $da=false; //don't show $ds=$E->SalesRank; if ($da or $ds) { echo $tab. " "; if ($ds) echo xl('sales rank').": <b>$ds</b>"; if ($da and $ds) echo ", "; if ($da) echo $tab.xl('customer rating').": <b>".(($da-1)*25)."%</b>"; echo "<br />\n"; } $do=$E->OfferSummary->LowestNewPrice ->FormattedPrice; $du=$E->OfferSummary->LowestUsedPrice->FormattedPrice; if ($do or $du) { echo $tab. " ".xl('price').": "; if ($do) echo "<b>$do</b> (".xl('new').")"; if ($do and $du) echo ", "; if ($du) echo "<b>$du</b> (".xl('used').")"; echo "<br />\n"; } echo $tab. " </td>\n"; if ($EditorialReviews=$E->EditorialReviews and $EditorialReview=$EditorialReviews->EditorialReview and $Content=$EditorialReview->Content) { echo $tab. " <td align='center'>\n"; echo $tab. " $Content\n"; echo $tab. " </td>\n"; } echo $tab. "</tr>\n"; } } //make link to other page (next, previous etc.) function make_link_to_page($page,$s) { global $language; global $locale; global $search; global $searchindex; global $searchparameter; global $searchparameterdata; return "<a href='?". 'language' .'='.$language .'&'. 'locale' .'='.$locale .'&'. 'page' .'='.$page .'&'. 'searchindex' .'='.$searchindex .'&'. 'searchparameter' .'='.$searchparameter .'&'. 'searchparameterdata'.'='.urlencode($searchparameterdata).'&'. "'>".xu($s)."</a>"; } //print an array or object //(for debugging) function print_array($A,$tab='') { if (is_object($A)) { echo $tab."object:<br >\n"; print_array((array)$A,$tab); } else if (is_array($A)) { // print_r($A); echo $tab."<table border='1'>\n"; echo $tab." <tbody>\n"; // echo $tab." COUNT=".count($A)."\n"; // if (is_object($A)) { // echo $tab." COUNT=".count($A)." - ".$A['0']."\n"; // } foreach ($A as $i=>$d) { echo $tab." <tr>\n"; echo $tab." <td valign='top'>$i</td>\n"; // print_r($d); if (is_string($d)) { // echo $tab." STRING\n"; // print_r($d); // echo $tab." <td><pre>".htmlentities($d)."</pre></td>\n"; echo $tab." <td>".htmlentities($d)."</td>\n"; } else if (is_array($d)) { // echo $tab." ARRAY or OBJECT\n"; echo $tab." <td>\n"; print_array($d,$tab.' '); echo $tab." </td>\n"; } else if (is_object($d)) { // echo $tab." ARRAY or OBJECT\n"; echo $tab." <td>object:\n"; print_array((array)$d,$tab.' '); echo $tab." </td>\n"; } else { // echo $tab." ELSE\n"; // print_r($d); // echo $tab." <td><pre>".htmlentities($d)."</pre></td>\n"; echo $tab." <td>".htmlentities($d)."</td>\n"; } echo $tab." </tr>\n"; } echo $tab." </tbody>\n"; echo $tab."</table>\n"; } else { echo $tab."warning: not-an-array-or-object given to print_array()<br />\n"; } } function getmicrotime() { list($us,$s)=explode(' ',microtime()); return (float)$us+(float)$s; } if ($f_user_search) { //the next section adds a search box for the users echo $tab. "<hr />\n"; echo $tab. "<form method='get' action='?'>\n"; //echo $tab." <input type='hidden' name='language' value='$language' />\n"; //echo $tab." <input type='hidden' name='locale' value='$locale' />\n"; //echo $tab." <input type='text' name='ty'>Search type</input><br />\n"; echo $tab. " <table>\n"; echo $tab. " <tbody>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('language for page:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='language'>\n"; foreach ($Alanguage as $i=>$d) { echo $tab." <option value='$i'".($i==$language?" selected='true'":"").">".xu($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('which server:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='locale'>\n"; foreach ($Alocale as $i=>$d) { echo $tab." <option value='$i'".($i==$locale?" selected='true'":"").">".xl($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('operation:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='operation'>\n"; foreach ($Aoperation as $i=>$d) { echo $tab." <option value='$i'".($i==$operation?" selected='true'":"").">".xu($i)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('product category:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='searchindex'>\n"; foreach ($Asearchindex as $i=>$d) { //uk and jp not ready yet? 20080730: must be adjusted to the locale again echo $tab." <option value='$d'".($d==$searchindex?" selected='true'":"").">".xl($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('search parameter:')."</td>\n"; echo $tab. " <td>\n"; echo $tab. " <select name='searchparameter'>\n"; foreach ($Aoperation['ItemSearch']['RequiredParameters']['SearchIndex'] as $i=>$d) { echo $tab." <option value='$d'".($d==$searchparameter?" selected='true'":"").">".xu($d)."</option>\n"; } echo $tab. " </select>\n"; echo $tab. " </td>\n"; echo $tab. " </tr>\n"; echo $tab. " <tr>\n"; echo $tab. " <td>".xu('search string:')."</td>\n"; echo $tab. " <td><input type='text' name='searchparameterdata' value='$searchparameterdata' /></td>\n"; echo $tab. " </tr>\n"; echo $tab. " </tbody>\n"; echo $tab. " </table>\n"; echo $tab. " <input type='submit' value='Search' />\n"; echo $tab. "</form>\n"; //end of the search box section } //phpinfo(); $Amicrotime['show' ][1]=getmicrotime(); //time after showing $Amicrotime['total'][1]=getmicrotime(); //time at end //The next part is to show if the script isn't overburdoning your server. (The time waiting for Amazon isn't burdoning your server). You can remove the next part if you like: echo $tab."<hr />\n"; //echo("Time used for time-consuming parts:<br />\n"); echo $tab."Time used:<br />\n"; foreach ($Amicrotime as $i=>$d) { //if ($d[1]>$d[0]) { printf($tab."- %.2f s %s<br />\n",$d[1]-$d[0],$i); //} } //20091129/wjvg: you may remove these lines or move them to an about section of your site: echo $tab."<hr />\n"; echo $tab."This script is GPL'ed and can be downloaded from <a href='http://www.chipdir.nl/amazon/'>this page</a>.<br />\n"; echo " </body>\n"; echo "</html>\n"; //end what I'm trying to workout to do before I go messing around with this script is to get it working in this pagehttp://mypcmates.com/pcparts.php if you look there you will see this text "Your text here test" to change this text you edit this page \styles\X_Silver\template\pcparts_body.html <!-- INCLUDE overall_header.html --> <!-- Your page can be changed to what ever you want displayed in this location. Now if you change the name of the file from something different then pcpart_body.html make sure you also make the chagne in php file as well. --> <div class="c-h-l"><div class="c-h-r"><div class="c-h-c"><div class="c-h-title"><h4>Your Page</h4> </div></div></div></div> <div class="v-left"><div class="v-right"> <div class="panel"> <div class="inner"><span class="corners-top"><span></span></span> <!-- Then information you wish to add to this page will go between the <div class="content"> and its closing div </div> you do not have to use the paragraphp codes if you do not wish. --> <div class="content"> <p> Your text here test </p> </div> <span class="corners-bottom"><span></span></span></div> </div> </div></div> <div class="c-f-l"><div class="c-f-r"><div class="c-f-c"></div></div></div> <!-- INCLUDE jumpbox.html --> <!-- INCLUDE overall_footer.html --> it would be great if you could help me work this out
  4. ok any way done a bit more I started this from scratch and went through it all again. before I had it all in AWS folder on my server, now I did it all again and put it in cgi-bin folder, now I get to these steps 5). Use your browser to go directly to the 'apf_config.cgi' file on your server, e.g. http://www.MY-DOMAIN.com/public_html...apf_config.cgi. 6). Because this is you first usage, you will have to enter a password and save it -- write the password down for use later Now I get this error " Forbidden You don't have permission to access /cgi-bin/ on this server." I set the permissions to allow read/write access on the ubuntu server by right clicking the folder and setting them but I still get the " Forbidden You don't have permission to access /cgi-bin/ on this server." error got any ideas
  5. Hi Guys I needed some help with this script http://apf.sourceforge.net/ I found on the web. it has these instructions to install it INSTALL: 1) Download the script archive and unpack the contents to a directory on your machine. 2) Make a new directory on your server, e.g. .../cgi-bin/aws. 3) Upload the APF files to the new .../cgi-bin-aws directory. 4). Ensure the CGI files 'apf.cgi', 'apf_test.cgi', and 'apf_config.cgi' have execute permissions set, e.g. chmod 755 *.cgi. 5). Use your browser to go directly to the 'apf_config.cgi' file on your server, e.g. http://www.MY-DOMAIN.com/public_html/cgi-bin/aws/apf_config.cgi. 6). Because this is you first usage, you will have to enter a password and save it -- write the password down for use later 7). Enter your Amazon IDs, AWS 'Access Key ID', and AWS 'Secret Access Key', and your default locale, you can leave most of the other fields unchanged, then enter your password and 'Save'. Test your efforts by using your browser to go to http://www.MY-DOMAIN.com/cgi-bin/aws/apf4_test.cgi and you should see Amazon debug confirmation stuff with Labb's default template 9). Change the page, product, and item template in the .../cgi-bin/aws/templates/default directory to your defaults and you should see your webpages with the Amazon debug messages. You also should copy over the contents of any other template directories that you are currently using into the new '...cgi-bin/aws' directory. 10). Now try it with the web link going to the '...cgi-bin/aws/apf4.cgi' in lieu of the '...cgi-bin/aws/apf4_test.cgi' and everything should work without the Amazon test messages. 11) To go operational, just change your real links to use '...cgi-bin/aws/apf4.cgi' in lieu of your previous script. 12) Optionally you can remove the apf4_test.cgi, as it is only needed for debugging purposes and is exactly the same as apf4.cgi. ok I'm up to this part here 5). Use your browser to go directly to the 'apf_config.cgi' file on your server, e.g. http://www.MY-DOMAIN.com/public_html/cgi-bin/aws/apf_config.cgi. 6). Because this is you first usage, you will have to enter a password and save it -- write the password down for use later but when I go there http://mypcmates.com/aws/apf_config.cgi it's not asking for a password what am I doing wrong? I'm new at this so yeah....
  6. I will explain why I'm looking at this code and trying to learn it so I can get the results I'm after, the table will be called "partslist" it will have these fields below, I want it to search NAME and DESCRIPTION fields for the search term, and when displaying the results it has all the information in NAME DESCRIPTION MANUFACTURER SALEPRICE PRICE BUYURL IMAGEURL ID NAME DESCRIPTION MANUFACTURER SALEPRICE PRICE BUYURL IMAGEURL would that be possible to do this by modifying this code?
  7. I renamed index.php to search.php and it works thanks so much! I was just wondering also with this code would it be possible to make it search more of the database? I was looking at the code below it searches the post_text field of the database, could it also search the post_id field of the database? $query = "select * from phpbb_posts where post_text like \"%$trimmed%\" order by post_text"; // EDIT HERE and specify your table and field names for the SQL query Your help has been great thanks!
  8. also if we can't work this out has anyone got some examples or links to a good guide on how to build a web page that searches a mysql database.
  9. tried that still the same it goes to this address http://mypcmates.com/testing/search.php?q=windows&Submit=Search and the page displays Not Found The requested URL /testing/search.php was not found on this server. Apache/2.2.12 (Ubuntu) Server at mypcmates.com Port 80 I'm very new at php, but there is no /testing/search.php file but I guess that is that this code is for <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form>
  10. I spoke to soon the page seems to load ok see here http://mypcmates.com/testing/index.php so 1 thing is fixed, thank you for that. But if I got to do a search it goes to this page http://mypcmates.com/testing/search.php?q=windows&Submit=Search with no results, this is the guide I'm trying to follow here http://www.designplace.org/scripts.php?page=1&c_id=25 found it via Google.
  11. stupid me I had a blond moment $trimmed = trim($var); //trim whitespace from the stored variable it works now thanks a bunch!
  12. Thanks for the quick reply I changed that line of code to this $trimmed = trim($var) //trim whitespace from the stored variable; But I still get this error Parse error: syntax error, unexpected T_VARIABLE in /var/www/testing/index.php on line 22 got any more suggestions to try, thanks for taking the time to help me out I appreciate it.
  13. Hello Guys I'm getting this error "Parse error: syntax error, unexpected T_VARIABLE in /var/www/testing/index.php on line 22" this is what's on line 22 "$limit=10; " from the code below, I'm new at PHP so idky it's happening any advice would be great! <html> <head> <title>designplace.org search script</title> <meta name="author" content="Steve R, http://www.designplace.org/"> </head> <!-- © http://www.designplace.org/ --> <body> <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form> <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var) //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","root","Kikass32"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("pchelp") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from phpbb_posts where 1st_field like \"%$trimmed%\" order by 1st_field"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; // google echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> <!-- © http://www.designplace.org/ --> </body> </html>
  14. Hi All great looking site I'm a total Noob at PHP so you will see me around a fair bit. Hope to make some friends around here
  15. Hi Guys Hoping someone is good with PHP I have an oscommerce project I'm working on I use the easy populate mod this one osCommerce: Easy Populate & Products Attributes it has 2 PHP files in the mod that allows you to import products from an excel file which works very well. The problem is in my data feed has the images as a url and when I put the http:// address in it won't fetch the image. But I've been chatting to a so called friend and he has had a look at the 2 php files and said I just need to modify one line of code for it to work but I have no idea what line and this so called friend won't tell me some friend hey! . Can someone please help or point in the right direction I don't know php [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.