Jump to content

simedogz

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

simedogz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hello all, I inserted a javascript event handler 'onclick' into php code. the onclick has a php variable in it that is supposed to trigger an alert when clicked. I can't figure out how to escape the php variable correctly, so I just left it at the last thing I tried, which I know is wrong. Any help is appreciated. thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function popUp(a) { alert(a); } </script> </head> <body> <?php $gmail ='yaaah'; echo '<p onclick=popUp(\'$gmail\')>lkjlkjlkjlkjlkjlkj</p>'; ?> </body> </html>
  2. Hello, I am trying to store data from a data feed into a database. The datafeed is an xml object. I am trying to store the price of different books in this database. to access the different prices in the xml document, I have been using a foreach loop. What I haven't figured out is how to use a foreach loop to write these values to a database. Here is the code I have come up with. However, I get a parse error. Can anyone tell me what I am doing wrong? thanks. <?php $url='https://product-search.api.cj.com/v2/product-search?website-id=3584291&advertiser-ids=1427863,829234,520129,1551419,904879,1191832,246072,1087150,2020232,2030865,1845757&isbn=0316346624&sort-by=price&serviceable-area=US'; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $CJ_KEY ='00bc6addff460bdfb61689a6b153deca753cad4b171931e2bd715099f511dbe1f72944588882ba974f7be7a7490faad8f034209a4c5bb9f510bbcf1a3f3b4a7a77/0090be60307cf51e34d9f78110f4e7500ce442144f785174682826cd3f112b23d8d44136d0f9b5b48ea8089521ec76e295dc50e1b2fa7754e2bb8905c05e152071'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $CJ_KEY)); $curl_results = curl_exec($ch); $info = simplexml_load_string($curl_results); print_r($info); foreach($info->products->product as $cost) { echo "<h3>" . $cost->price . "</h3>"; }; // Database entries $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("results", $con); //code that doesn't work foreach($info->products->product as $cost2) { mysql_query("INSERT INTO search_results (seller_name, price, description, buy_url, date) VALUES ('haha', '$cost2->price', 'good', 'www.blah.com', CURDATE())"; }; // end of code that doesn't work // test that data is getting through to the database mysql_query("INSERT INTO search_results (seller_name, price, description, buy_url, date) VALUES ('blaah', '', 'good', 'www.xyz.com', CURDATE())"); mysql_close($con); ?>
  3. Hello all, I am trying to Utilize Commission Junction's API. I tried using SOAP, but I could not get it to work. So now I am trying REST, which seems simpler. However, I am running into problems with the REST request. I am trying to get the sample code CJ publishes on their website to run. Here is the sample URI: https://product-search.api.cj.com/v2/product-search?website-id=12345678keywords=GPS&serviceable-area=US In addition they mention, " Commission Junction's REST Web Services use the standard HTTP Authorization header to pass authentication information. You must provide your developer key to pass authentication. The request URI for the Publisher Lookup Service API must be properly encoded based on HTML 4 specification form content encoding rules. Please refer to http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4 for the standard specification. " How do I sender a header authorization with PHP? What all needs to be in it? I know about Header()... but how does one know how to send the Authorization ID and what syntax to use? For more info, here is Commission Junction's webpage regarding APIs: http://help.cj.com/en/web_services/web_services.htm#api_hosts.htm Thanks for your help
  4. Hello all, I am trying to retrieve the "MediumImage" from this XML document using PHP. How would I do this? I tried using SimpleXML, but I get this error: Notice: Trying to get property of non-object in C:\wamp\www\parsingattempt2.php on line 8 here is my php code: <?php $request_url = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=0XQ36T5736VESGZK91G2&Operation=ItemLookup&ItemId=0679722769&ResponseGroup=ItemAttributes,Offers,Images,Reviews&Version=2009-01-06"; $xml = simplexml_load_file($request_url) or die("feed not loading"); $Book_Image = $xml->MediumImage->URL; echo "$Book_Image"; ?> Attached is the XML file where I am trying to extract the "MediumImage" URL. Note that I have changed it into a txt file to upload it. You should be able just to change the filename to .xml. Thanks for your help. [attachment deleted by admin]
  5. Hello, this is a great resource I stumbled upon. I am a total beginner and am trying to do this php tutorial: http://devzone.zend.com/node/view/id/626, The code prompts a user to enter some text into a form. a separate php 'page' displays the output. For some reason this is not working. When I enter text into the text box and press send, message.php opens up but nothing is displayed. Here is the form code(form.html): <html> <head></head> <body> <form action="message.php" method="post"> Enter your message: <input type="text" name="msg" size="30"> <input type="submit" value="Send"> </form> </body> </html> Here is the php code (message.php) <html> <head></head> <body> <?php // retrieve form data $input = $_POST['msg']; // use it echo "You said: <i>$input</i>"; ?> </body> </html>
×
×
  • 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.