Am trying to create a new variable which consists of a string and the key from the database and store it as a session variable, but cannot seem to get the syntax correct. I have checked my ”SELECT” in the SQL window directly against the MySQL database and get the Key value in return. So what is wrong in my code below?
[php]$query = “SELECT Key FROM Sites ORDER BY Key DESC LIMIT 1”;
$result = mysql_query($query, $conn_id);
$key = mysql_result($result,0,0);
$siteid = “eSRA”."$key";
$session->set( ‘siteid’, $siteid);[/php]
When I execute the above I get the following results depending on the syntax on the second last line:
[php]$siteid = “eSRA”.$key;[/php] results in the string eSRA
[php]$siteid = “eSRA”."$key";[/php] results in the string eSRA
[php]$siteid = “eSRA”."’$key’";[/php] results in the string eSRA’
[php]$siteid = “eSRA”.’$key’;[/php] results in the string eSRA$key
[php]$siteid = “eSRA”.’"$key"’;[/php] results in the string eSRA”$key”
But nowhere do I get the result eSRA20 which is what I am after. I can’t figure out which of the following two lines is wrong, but I am almost sure it is one of them:
[php]
$key = mysql_result($result,0,0);
$siteid = “eSRA”."$key";
[/php]
Help!?