Re: Having Trouble With Session Variable in Query Statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On February 23, 2009 15:34:58 revDAVE wrote:
> Hi folks,
>
> //but this does not..
> $updateSQL ="UPDATE `mytable` SET thetotal=$amt WHERE
> id=$_SESSION['thisid']";
>
> Q: How can I fix it?

try :
 $updateSQL ="UPDATE `mytable` SET thetotal=$amt WHERE
  id={$_SESSION['thisid']}";

or even better:
 $updateSQL ="UPDATE `mytable` SET thetotal=".mysql_real_escape_string($amt).
  " WHERE id=".mysql_real_escape_string($_SESSION['thisid']);

substituting mysql_real_escape_string with the escape function for your 
database.
-- 
Philip Graham
Lightbox Technologies
Suite 312 240 Catherine St.
Ottawa, ON, K2P 2G8
613-686-1661 ext. 102

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux