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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-17-2009, 02:47 AM   #1
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-17-2009, 02:48 AM   #2
grumpy
Too lazy to set a custom title
 
grumpy's Avatar
 
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;';
its ".$id."
__________________
Don't let greediness blur your vision | You gotta let some shit slide
icq - 441-456-888

Last edited by grumpy; 12-17-2009 at 02:50 AM..
grumpy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-17-2009, 03:17 AM   #3
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by grumpy View Post
Code:
mysql_select_db($mysql);
$query = 'UPDATE `sms`.`messages_import` SET `timestamp` = NOW(), `status` = \'2\' WHERE `messages_import.id` = `".$id."` LIMIT 1;';
its ".$id."
Thanks got it working with '.$id.'
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-17-2009, 03:30 AM   #4
darksoul
Confirmed User
 
darksoul's Avatar
 
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";
You also don't need LIMIT 1, since the id is unique (in most cases anyway)
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-17-2009, 06:51 AM   #5
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
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.
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.