Web Hosting Talk







View Full Version : Why dose this not work?


Danny159
08-27-2007, 02:24 PM
Hey

Why dose this not work

SELECT * FROM invoice WHERE clientid = '$_SESSION['username']' ORDER BY id

I have a <?php include("check.php"); ?> at the top of the script so thats where the username comes from

I get this error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/master/public_html/customers/old/new/invoice/view.php on line 17

sasha
08-27-2007, 02:37 PM
This would work:
SELECT * FROM invoice WHERE clientid = '{$_SESSION['username']}' ORDER BY id

or better

SELECT * FROM invoice WHERE clientid = '" . mysql_real_escape_string($_SESSION['username']) ."' ORDER BY id

Jatinder
08-27-2007, 02:42 PM
"SELECT * FROM invoice WHERE clientid = '{$_SESSION['username']}' ORDER BY id"

Danny159
08-27-2007, 02:58 PM
Thanks mate