Jump to content

Recommended Posts

Hello,
When I run this part of the script
[code=php:0]mysql_query("INSERT INTO paypal_sales (viewed_online, viewed_online_by_ip) VALUES('$datenow', '$ip') where $txn_id = $txn_id ")
or die(mysql_error());[/code]

I get the error
[CODE]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 0UU67926P08484626 = 0UU67926P08484626' at line 1[/CODE]

If I remove it the script works fine again.. What do you think can be the problem?

Best Regards
Oskar R
actually, the problem is that you cannot use a WHERE clause at all in an INSERT query like that.  The INSERT query inserts a new row into your table.  End of story.  If you are trying to add a new row to your table, then take off the where clause and you're done.  If you are trying to edit a row, then you need to use UPDATE not INSERT like

mysql_query("UPDATE paypal_sales SET viewed_online='$datename', viewed_online_by_ip='$ip' WHERE ....") or die(mysql_error());

now normally you would add

... WHERE $txn_id = $txn_id

at the end there..but I don't think you've done that right ether. If you were to add that to the end, it would update every single row, because that condition would return true every time because you are comparing a variable to itself.  I think what you probably wanted to do was

... WHERE txn_id_column_name_here = $txn_id
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.