Jump to content

In a query, why does $_SESSION[cid] work, but $_SESSION['cid'] not work?


darp

Recommended Posts

In this link quotes withing a global session array are clarified  http://www.phpfreaks.com/forums/mysql-help/%28solved%29-confused-as-to-what-quote-mark-to-use-in-a-query/

 

However I can't get $_SESSION['cid'] to work.

 

Could someone explain to me why this works:

 

$mysql = "UPDATE customer SET menulist = ' $menulist ', packlist = ' $packlist ' WHERE customer ='$_SESSION[cid]'";

     

mysql_query($mysql); 

           

Where as this does not.

 

$mysql = "UPDATE customer SET menulist = ' $menulist ', packlist = ' $packlist '  WHERE customer =" . $_SESSION['cid'];

     

mysql_query($mysql); 

 

What would the proper syntax/format be?

Thanks for the fast reply. This works. Do I have it right or can I improve on it?

 

$mysql = "UPDATE customer SET menulist = ' $menulist ', packlist = ' $packlist '  WHERE customer =  '{$_SESSION['cid']}'";

   

mysql_query($mysql); 

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.