kjavia795 Posted July 31, 2008 Share Posted July 31, 2008 $qry = "INSERT INTO lt_tickets (userid) VALUES ("$item_name") "; $result = mysql_query($qry,$db); im getting an unexpected T_VARIABLE my entire script is this: <?php //------------------------------------------------------------------ // Open log file (in append mode) and write the current time into it. // Open the DB Connection. Open the actual database. //------------------------------------------------------------------- $db = mysql_connect("localhost", "zeronicx_lew", "password1"); mysql_select_db("zeronicx_raffle2",$db); //------------------------------------------------ // Read post from PayPal system and create reply // starting with: 'cmd=_notify-validate'... // then repeating all values sent - VALIDATION. //------------------------------------------------ $postvars = array(); while (list ($key, $value) = each ($HTTP_POST_VARS)) { $postvars[] = $key; } $req = 'cmd=_notify-validate'; for ($var = 0; $var < count ($postvars); $var++) { $postvar_key = $postvars[$var]; $postvar_value = $$postvars[$var]; $req .= "&" . $postvar_key . "=" . urlencode ($postvar_value); } //-------------------------------------------- // Create message to post back to PayPal... // Open a socket to the PayPal server... //-------------------------------------------- $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 ("www.paypal.com", 80, $errno, $errstr, 30); //---------------------------------------------------------------------- // Check HTTP connection made to PayPal OK, If not, print an error msg //---------------------------------------------------------------------- if (!$fp) { echo "$errstr ($errno)"; fwrite($log, "Failed to open HTTP connection!"); $res = "FAILED"; } //-------------------------------------------------------- // If connected OK, write the posted values back, then... //-------------------------------------------------------- else { fputs ($fp, $header . $req); //------------------------------------------- // ...read the results of the verification... // If VERIFIED = continue to process the TX... //------------------------------------------- while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { }}} $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']; $qry = "INSERT INTO lt_tickets (userid) VALUES ("$item_name") "; $result = mysql_query($qry,$db); //------------------------------------------- // Close PayPal Connection, Log File and DB. //------------------------------------------- fclose ($fp); mysql_close($db); ?> Link to comment https://forums.phpfreaks.com/topic/117643-uggh-stupid-error-help/ Share on other sites More sharing options...
trq Posted July 31, 2008 Share Posted July 31, 2008 Nothing stupid about it, your query ought be.... $qry = "INSERT INTO lt_tickets (userid) VALUES ('$item_name')"; Link to comment https://forums.phpfreaks.com/topic/117643-uggh-stupid-error-help/#findComment-605090 Share on other sites More sharing options...
kjavia795 Posted July 31, 2008 Author Share Posted July 31, 2008 It still isn't writing anythign into the database, can't figure out why Link to comment https://forums.phpfreaks.com/topic/117643-uggh-stupid-error-help/#findComment-605098 Share on other sites More sharing options...
trq Posted July 31, 2008 Share Posted July 31, 2008 Lets see if your getting any error and what your query looks like... $result = mysql_query($qry,$db) or die(mysql_error() . $qry); ps: Your code is really hard to read because of a lack of indentation. Link to comment https://forums.phpfreaks.com/topic/117643-uggh-stupid-error-help/#findComment-605100 Share on other sites More sharing options...
kjavia795 Posted July 31, 2008 Author Share Posted July 31, 2008 $qry = "INSERT INTO lt_tickets (`id`, `user_id`, `lottery_id`, `won`, `price`, `date`) VALUES (NULL, \'$item_name\', \'0\', \'0\', \'0\', \'0\')"; $result = mysql_query($qry,$db); That is what I am using, and its not doing it. Link to comment https://forums.phpfreaks.com/topic/117643-uggh-stupid-error-help/#findComment-605102 Share on other sites More sharing options...
ronnie88 Posted July 31, 2008 Share Posted July 31, 2008 like thorpe said instead of the result like you have right now replace it with this and it should give you an error to the cause of why its not inserting $result = mysql_query($qry,$db) or die(mysql_error() . $qry); Link to comment https://forums.phpfreaks.com/topic/117643-uggh-stupid-error-help/#findComment-605116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.