Jump to content

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


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); 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.