I'm running this code in PHP:
mysql_query("SET @update_id:=NULL");
echo mysql_error();
And this is what 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 '' at line 1
Also this same code runs perfectly in PHPMyAdmin. What am I doing wrong?
Additional information. I'm trying to write a query described here: How to get ID of the last updated row in MySQL? But the problem right now is that I even can't run a simple query to create variable.
P.S. Ok, now it seems that it desn't work because of some previous queries that are not related to this one. If i move this query to the top of the php file it works. Also if I try to make this:
mysql_query("SET @update_id:=NULL; SELECT @update_id;"); It fails with syntax error. But this works fine: mysql_query("SET @update_id:=NULL;"); mysql_query("SELECT @update_id;"); Does somebody knows what am I missing here? Why can't I run two commands in one query and why they're the separate queries are related to each other?