![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Too lazy to set a custom title
Join Date: Jan 2002
Location: Holland
Posts: 9,870
|
Code:
mysql_select_db($mysql); $query = 'UPDATE `sms`.`messages_import` SET `timestamp` = NOW(), `status` = \'2\' WHERE `messages_import.id` = `".$id."` LIMIT 1;';
__________________
Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
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"; |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Bollocks
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,793
|
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.
__________________
Interserver unmanaged AMD Ryzen servers from $73.00 |
![]() |
![]() ![]() ![]() ![]() ![]() |