Jump to content

[SOLVED] mysql session


yogibear

Recommended Posts

Hi

 

I have a mysql query and I want to use a session to select from the database WHERE username equals the contents of the session. Sorry if I have not been clear, I am finding it difficult to explain. My attempt at the code may make it easier to understand what I am trying to do.

 

$result = mysql_query("SELECT * FROM User
WHERE Username='$_SESSION["username"]'");

 

I have tried this code but I get an error.

 

Best wishes

yogi

Link to comment
https://forums.phpfreaks.com/topic/119470-solved-mysql-session/
Share on other sites

try

$result = mysql_query("SELECT * FROM User
WHERE Username='$_SESSION[username]'");

 

More syntactically correct, but technically there's nothing wrong with your code

 

$result = mysql_query("SELECT * FROM User
WHERE Username='{$_SESSION['username']}'");

Link to comment
https://forums.phpfreaks.com/topic/119470-solved-mysql-session/#findComment-615432
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.