Can somebody please give me the corect syntax for the following query, I am finding it difficult to pass the username of a session in a query. I have tried so many ways to implement this, but it just won't work...
These are some of the methods I have tried! What am I doing wrong. It's in PHP by the way!
Code: Select all
$q = "SELECT user, message, senttime "
."FROM ".TBL_AUCTION_RESPONSES." WHERE user=".$session->username." ORDER BY senttime DESC";
$q = "SELECT user, message, senttime "
."FROM ".TBL_AUCTION_RESPONSES." WHERE user='.$session->username.' ORDER BY senttime DESC";
$q = "SELECT user, message, senttime "
."FROM ".TBL_AUCTION_RESPONSES." WHERE user='<?php echo $session->username;?>' ORDER BY senttime DESC";If I use a string in the query as seen below in bolded letters, the query works just fine!
$q = "SELECT user, message, senttime "
."FROM ".TBL_AUCTION_RESPONSES." WHERE user='grant' ORDER BY senttime DESC";
Can somebody tell me what the syntax should be for variables in a case like this
Thanks
Grant