Jump to content

drew7721

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by drew7721

  1. GOT IT ! <?php $refurl = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY); parse_str($refurl, $info); echo $info['q']; ?>
  2. Ok, first let me tell you what I want to do. Google sends me traffic from many keywords, but I want to track what keyword does best for me as sales and so. The Analytics is good but I can't send the data to outside sites. So I figured this out : from the $_SERVER['HTTP_REFERER'] I can get the "q" value from the _GET and pass it on to track it... now I'm kind of stuck and I know it's easy but can't seem to find the function. This is what I have so far: /* Code to try and store the keyword that was used to find and land on my site. */ $exurl = 'http://www.google.ca/url?sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ'; //set a demo refferer url that would usually be $exurl = $_SERVER['HTTP_REFERER'] $refurl = parse_url($exurl, PHP_URL_QUERY); // remove all before and including the "?" echo $refurl; // echo "sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ" Ok, so I managed to get the important part out of the google URL, now how do I split this into an array that I can then use. For instance somefunction($refurl, $newarray); and then I could say | echo $newarray['q']; | and it would echo "mykeyword" Of course If there is a space in the keywords I should use the urldecode() function to avoid the % char... Let me know if you know of any way to get this done.
  3. hey ignace! tried your version and it works great! Is there a place where I can read more on the funcions you used there and if there are more xml functions I can use... hard to find some good techniques and examples.. thx.
  4. nice! thx for the replys I'll test them out and get back to you asap! I hope this works!
  5. Hey! I'm trying to get a php code to read, mod and display information from an xml or RSS file.. and it's really more that a mess. Everyone told me it's easy but there must be something i'm doing wrong. First, the projet is to get Tv Shows news to display on a site. I got the api and RSS feeds form TVrage.com site and they update the xml contend daily, so all I need to do is to get the file and save it on my server for faster reading. (that I know how). Here is a sample of an rss file with the new shows that will play today : <?xml version="1.0"?> <channel> <title>TVrage</title> <link>http://www.tvrage.com/</link> <description>TVrage</description> <language>en-us</language> <pubDate>Thu, Jun 3 2010 11:23:56 PDT</pubDate> <ttl>60</ttl> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <item> <title>08:00 pm</title> <link>http://www.tvrage.com</link> </item> <item> <title>- Good Eats (14x02)</title> <link>http://www.tvrage.com/Good_Eats</link> <description>Grillus Domesticus</description> </item> <item> <title>- So You Think You Can Dance (07x03)</title> <link>http://www.tvrage.com/So_You_Think_You_Can_Dance</link> <description>Auditions #5 and #6 / Vegas Callbacks, Part 1</description> </item> <item> <title>- My First Place (13x05)</title> <link>http://www.tvrage.com/shows/id-6829</link> <description>Buying a Home Sight Unseen</description> </item> <item> <title>- WWE Superstars (02x08)</title> <link>http://www.tvrage.com/shows/id-22359</link> <description>060310</description> </item> </channel> now I saved this file as today.xml on my server and it updates every 24 hours trough a php code fread() etc.. What I want to do is to only display the titles of the shows that will play today, no time, no description or link. Is there a way to do that? I'm sure there is, but i'm really new to this whole xml thing and I don't get it. I mean I have no problems to work with a MySql db but this, xml, my brain just does not process it! This is the piece of code I got so far from W3 schools : <?php $xml = simplexml_load_file("today.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } ?> As you can see if you test it, it does not do quite what I want it to do. P.S. I'm not sure if I am in the right section of forum, sorry.. did not find any related articles to xml issues. Thank's in advance 4 your help.
  6. thank you! it works! YEAH ! radom words! <?php $limit=10; // set how many vatriations are wanted function randomtext() //setting funtion { $words = func_get_args(); //getting words from function $word = array_rand($words,1); // pick one random word return $words[$word]; // return picked word } if(empty($i)) { //decleare value of $i $i=1; } while($i<$limit) // do loop { echo randomtext("favorite","best","awsome","excellent").' - '.randomtext("test1","test3","test4").'<br />'; //echo words $i++; } //inrease value ?>
  7. Hello, I have this issue with the following code. I'm trying to generate random words from an array of given words. The problem is that I do not want to limit/force the ammount of words it needs to be able to randomize. baisically I want to be able to put : randomtext("word1","word2","word3","word4") randomtext("word5","word6") randomtext("word7","word8","word9") so that the function takes in consiteration the words no matter the ammount 2 or 20 and randomizes the output. Is there anyway to include all variables from function in the array ? here is the code : <?php $limit=10; // set how many vatriations are wanted function randomtext($value1,$value2,$value3,$value4) //setting funtion { $words = array($value1,$value2,$value3,$value4); //getting words from function $word = array_rand($words,1); // pick one random word return $words[$word]; // return picked word } if(empty($i)) { //decleare value of $i $i=1; } while($i<$limit) // do loop { echo randomtext("favorite","best","awsome","excellent").' - '.randomtext("test1","test2","test3","test4").'<br />'; //echo words $i++; } //inrease value ?> Thank you
  8. Hi! I'm looking to make a dropdown menu based on a db table SQL table: Categories cat_id = INT auto_increase PRIMARY cat_name = VARCHAR (80) parent_id = INT NOT NULL default 0 ------------- Now I want to populate this table with categories and sub categories. Main categories get 0 as parent_id Now I want to add a sub cat so I'll give it a parent_id = 1 for it's parent cat to be the cat with cat_id =1 But I want to make a dropdown menu on site that will show PARENT CAT 1 ---subcat 1.1 ---subcat 1.2 PARENT CAT 2 ---subcat 2.1 ---subcat 2.2 PARENT CAT 3 PARENT CAT 4 ---subcat 4.1 ETC! how do I do this? I've been killing myself over this? can someone help please???
  9. Hello bemax! I'm not an expert, really not but maybe this can help... Iwas trying to do the same thing not to long ago and it's true it's easyer to save the directory path as varchar but if you really need to you can make a BLOB instead of a VARCHAR and there you can save raw pictures or pdf files to later recuperate from your website. here is a little script that worked for me be4 but really slows down database. I can't really explain it to you but a fast google search for mysql blob should get you going. $file = fopen ($_FILES["userfile"]["tmp_name"], "rb" ); //get temp size $size = filesize ($_FILES["userfile"]["tmp_name"]); //read temp file $content = fread ($file, $size); //protects by / / $userfile = addslashes ($content); $sql = "INSER INTO image (image) VALUES ("'{$userfile}'" )"; @mysql_query ($sql, $connection); // gets picpour recuperer l'image $sql = "SELEC * FROM image WHERE image_id=".$id_image; $result = mysql_query ($sql, $connection); if (mysql_num_rows ($result)>0) { $row = @mysql_fetch_array ($result); //gets bontent in binary mode $image = $row["image"]; //shows pic echo $image; there are a lot of codes out there that can help you out! hope you get a good grade
  10. Ok, I've tryed this code but still wont insert in my db, I connect to db in <?php require_once('../Connections/RestoA.php'); ?> .. the code for that is : Code for ../Connections/RestoA.php <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_RestoA = "my host"; $database_RestoA = "my database"; $username_RestoA = "my username"; $password_RestoA = "my pass"; $RestoA = mysql_pconnect($hostname_RestoA, $username_RestoA, $password_RestoA) or trigger_error(mysql_error(),E_USER_ERROR); ?> This was auto done my dreamweaver So the connection is OK now this is my transactions page .php. script: <?php require_once('../Connections/RestoA.php'); ?> <?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { mysql_query("INSERT INTO transaction VALUES('$item_name','$item_numbe','$payment_status','$payment_amount','$payment_currency','$txn_id','$receiver_email','$payer_email')"); // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> As you see I try to save the info from paypal to db : if (strcmp ($res, "VERIFIED") == 0) { mysql_query("INSERT INTO transaction VALUES('$item_name','$item_numbe','$payment_status','$payment_amount','$payment_currency','$txn_id','$receiver_email','$payer_email')"); What is my mistake??
  11. Hello!! I want my php to take info from Paypal and save it into my MyQSL database. I have this script from paypal : (it validates that the IPN (Instant Payment Notification) is ok and it should be able to save the info to MySql db) The script: <?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation } } fclose ($fp); } ?> #Now I need to add something to this script that will make it connect to my mysql database and save the info from variables sent by paypal to my database. (item_name, item_number, payment_status... etc.) =============================== 2nd problem.. : ??? ??? Now There is also the checking of : // check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment this I see where it goes in the script.... but i don't know what to write... This is what it has to do... 1, // check the payment_status is Completed check that $payment_status= completed 2, // check that txn_id has not been previously processed check that the $txn_id is unique in the database (has not been saved before) 3. // check that receiver_email is your Primary PayPal email check that the $receiver_email = to my email (ex something@domain.com) Thx a million 4 your help!! you can contact me at drew7721@gmail.com for questions.. Thx
×
×
  • 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.