Jump to content

It was working, but for some reason its not now


Xyphon

Recommended Posts

I was putting UserPosition in comments. I have the row and everything.

 

The cookie is set, I checked, but for some reason it wont add the position to the DB, it did before.

 

 

Look:

 

 setcookie("UserID", "$UserID", time() + 9999999);
setcookie("UserPosition", "$UserPosition", time() + 9999999);
setcookie("UserName", "$UserName", time() + 9999999);

 

Thats from login

 

This is from post comment

 

$submit = $_POST['submit'];
$username = $_COOKIE['UserName'];
$userID = $_COOKIE['UserID'];
$comment = $_POST['comment'];
$userposition = $_COOKIE['UserPosition'];
if (!isset($_COOKIE['UserID'])) {

echo "Sorry, you are not logged in. Please <a href='login.php'>login</a>.";
include('bottom.php');
exit;
}
if ($submit) {


mysql_query("INSERT INTO news_comments (username,comment,user_id,UserPosition) values ('$username','$comment','$userID','$userposition')") or die(mysql_error());

echo "The comment is successfully posted. Please go <a href='index.php'>back</a>";
}
else

 

Whats wrong there?

 

 

From that code, it would be safe to guess that $UserPosition doesn't actually have a value when you save it into the cookie. Make sure it is capitalized corretly and that it has a value. Print it before you set it into the cookie and see what the value actually is.

From that code, it would be safe to guess that $UserPosition doesn't actually have a value when you save it into the cookie. Make sure it is capitalized corretly and that it has a value. Print it before you set it into the cookie and see what the value actually is.

 

It does, its saved in my users database exactly like that.

 

Revraz: Isnt whattt you were talking about before the same as type? Because type says Varchar

Do the same line but switch $userposition with $_COOKIE['UserPosition'], my guess is that you will get the same thing, which goes back to my original guess that $UserPosition, when setting the cookie, isn't correct. Try adding an echo line right before setting the cookie that echos the $UserPosition.

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.