Jump to content

How do you store a php cookie value in a database?


debuitls

Recommended Posts

Hi,

 

This is a bit basic but anyway..

 

I have a php cookie called “uname” that stores a username.

 

I want to store this “uname” cookie value in a mysql database.

 

When I run the page with below code I just get a HTTP 500 error.

 

$username = $check["uname"];

 

$sql="INSERT INTO proposal (username)

 

VALUES

 

(‘$_COOKIE[“uname”]’)”;

 

I’m new to php so just wondering if anyone could tell me if I’m going about this in the right way and if so what the problem with the above code is.

 

Any help would be greatly appreciated!

 

 

Hi,

 

This is a bit basic but anyway..

 

I have a php cookie called “uname” that stores a username.

 

I want to store this “uname” cookie value in a mysql database.

 

When I run the page with below code I just get a HTTP 500 error.

 

$username = $check["uname"];

 

$sql="INSERT INTO proposal (username)

 

VALUES

 

(‘$_COOKIE[“uname”]’)”;

 

I’m new to php so just wondering if anyone could tell me if I’m going about this in the right way and if so what the problem with the above code is.

 

Any help would be greatly appreciated!

 

try :

 

$sql = "INSERT INTO proposal(username) VALUES('$username')";
$result = mysql_query($sql);

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.