Reputation: 540
I've been scratching my head for the last hour and just can't get this to work.
Doing this query:
$dbtoken = mysql_real_escape_string($invite_token);
$dbexpire = mysql_real_escape_string($invite_expire);
$dbid = mysql_real_escape_string($uid);
$update_user = mysql_query("UPDATE inviters SET invitetoken='$dbtoken', inviteexpire='$dbexpire' WHERE uid='$dbid'");
$save = mysql_query($update_user) or die(mysql_error());
It gives me this error:
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 '1' at line 1
Upvotes: 0
Views: 69
Reputation: 11830
There is a error You are trying to execute your query twice. Remove second execution of it.i.e remove this
$save = mysql_query($update_user) or die(mysql_error());
it is trying to do this
$save = mysql_query(1);
which is wrong
Upvotes: 1
Reputation: 3546
You are sending the result of your first query as an sql statement for your second query:
$update_user = mysql_query("UPDATE inviters SET invitetoken='$dbtoken',
inviteexpire='$dbexpire' WHERE uid='$dbid'");
$save = mysql_query($update_user) or die(mysql_error());
$update_user contains the result, and you feed it back to mysql_query. Try this instead:
$update_user = "UPDATE inviters SET invitetoken='$dbtoken',
inviteexpire='$dbexpire' WHERE uid='$dbid'";
$save = mysql_query($update_user) or die(mysql_error());
BTW: Use Mysqli instead of Mysql_ statements, they're deprecated and unsafe.
Upvotes: 1
Reputation: 11832
You are doing mysql_query();
twice. Once in the last line. And once in the line above it.
The first time it returns 1
(success)
The second time you try to execute 1
as a query
Ps. Scratching your head for an hour can cause skin irritation.
Upvotes: 0