Help with quotes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cone13cone
Forum Newbie
Posts: 24
Joined: Fri Mar 20, 2009 8:32 pm

Help with quotes

Post by cone13cone »

I have an issue with single quotes in my update queries maybe someone can shine some light on this for me.

Code: Select all

 
$query = "UPDATE `properties` 
          SET 
          `ZID` = '$zid',
          `name` = '$name' 
          WHERE `PID` = $pid 
          LIMIT 1;";
 
While this does not:

Code: Select all

 
$query = "UPDATE 'properties' 
          SET 
          'ZID' = '$zid',
          'name' = '$name' 
          WHERE 'PID' = $pid 
          LIMIT 1;";
 
so obviously ` != ' but could someone explain this to me.
Thanks John.
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Re: Help with quotes

Post by thisbl00d »

i'll be as simple as possible

Dont use single quotes with Table Field names or table names.
Use single quotes only with variables that have $ symbol.

try this

Code: Select all

 
mysql_query("Update users
                SET user_pwd = '$newpasswd'
                WHERE user_email = '$_SESSION[user]'
                ") or die(mysql_error());
this works perfect for me on
phpversion > 5
Mysqlversion > 5

cheers
Post Reply