Page 1 of 1

Help with quotes

Posted: Sun Mar 22, 2009 2:05 pm
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.

Re: Help with quotes

Posted: Sun Mar 22, 2009 2:18 pm
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