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?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.