![]() |
Mysql $query = Update $variable field quick php question
First time using the update command.
Basically trying to change the status from 1 to 2 which works with this query without the $id variable I inserted. Anyone know how I format the $id variable properly in this query? mysql_select_db($mysql); $query = 'UPDATE `sms`.`messages_import` SET `timestamp` = NOW(), `status` = \'2\' WHERE `messages_import`.`id` = `"$.id."` LIMIT 1;'; Again I tried a few common variations that I knew of like $id, '$id', etc but nothing seemed to work :( Mucho appreciatedo |
Code:
|
Quote:
|
thats a pretty fugly style with all those escapes. The only escape you need is for timestamp which is a reserved keyword
Code:
$query = "UPDATE sms.messages_import SET `timestamp` = NOW, status=2 WHERE messages_import.id=$id"; |
When you are running queries you're not sure of, always use this format for the query call (assuming you're using the old style mysql calls):
$result = mysql_query($query) or die(mysql_error() . ", query was $query"); Then not only can you see what the error was, you can see why the query string caused it. |
| All times are GMT -7. The time now is 09:11 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123