ShaolinF Posted January 31, 2008 Share Posted January 31, 2008 Hi Guys, Keep getting Parse error: syntax error, unexpected T_VARIABLE for the following mysql_query("INSERT INTO purchase (pp_txn_id, pp_payment_date, pp_pending_reason) VALUES ('".$_POST['txn_id']."', '".$_POST['payment_date']."', '".$_POST['pending_reason']."') WHERE purchaseid = '"$_POST['invoice']"' ") or die ($error = mysql()); The error is pointing to the third line of code. Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/ Share on other sites More sharing options...
ShaolinF Posted January 31, 2008 Author Share Posted January 31, 2008 Man, can't edit it. I fixed it. But here is the new message I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE purchaseid = ''' at line 3 Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454778 Share on other sites More sharing options...
revraz Posted January 31, 2008 Share Posted January 31, 2008 Post the new query, you have a problem before the WHERE Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454788 Share on other sites More sharing options...
ShaolinF Posted January 31, 2008 Author Share Posted January 31, 2008 mysql_query("INSERT INTO purchase (pp_txn_id, pp_payment_date, pp_pending_reason) VALUES ('".$_POST['txn_id']."', '".$_POST['payment_date']."', '".$_POST['pending_reason']."') WHERE purchaseid = $_POST['invoice'] ") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454794 Share on other sites More sharing options...
revraz Posted January 31, 2008 Share Posted January 31, 2008 echo the query to see what it actually looks like Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454798 Share on other sites More sharing options...
ShaolinF Posted January 31, 2008 Author Share Posted January 31, 2008 This is what is says: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE purchaseid = 1' at line 3 Echo doesn't work.. Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454812 Share on other sites More sharing options...
revraz Posted January 31, 2008 Share Posted January 31, 2008 You are doing a INSERT and using WHERE, you can't do that. INSERT inserts a new Row. If you have an existing Row, use the UPDATE function. Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454816 Share on other sites More sharing options...
chum Posted January 31, 2008 Share Posted January 31, 2008 rofl, yea...you can't use where with insert.. Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454818 Share on other sites More sharing options...
ShaolinF Posted January 31, 2008 Author Share Posted January 31, 2008 hah, thanks. How could I have missed that one, I need to get some sleep! Link to comment https://forums.phpfreaks.com/topic/88797-solved-mysql-query/#findComment-454819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.