Xyphon Posted December 18, 2007 Share Posted December 18, 2007 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? Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 18, 2007 Share Posted December 18, 2007 Are you getting the "Sorry, you are not logged in..." message, or is it putting everything in the db except the userposition? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 18, 2007 Share Posted December 18, 2007 Is your DB set to Int or Varchar for Userposition? Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 18, 2007 Author Share Posted December 18, 2007 Varchar Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 18, 2007 Author Share Posted December 18, 2007 Are you getting the "Sorry, you are not logged in..." message, or is it putting everything in the db except the userposition? Putting everything in but userposition Quote Link to comment Share on other sites More sharing options...
revraz Posted December 18, 2007 Share Posted December 18, 2007 And what type is Userposition in your code, Int or String? Varchar Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 18, 2007 Share Posted December 18, 2007 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. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 18, 2007 Author Share Posted December 18, 2007 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 Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 18, 2007 Share Posted December 18, 2007 Didn't you say it won't save to the database? What happens if you add a line to your code like this? //... if ($submit) { echo $userposition . "<br>"; mysql_query("INSERT //... See what that displays. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 18, 2007 Author Share Posted December 18, 2007 It just makes it do <br> Hmm.. But It IS capitalized properly Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 18, 2007 Share Posted December 18, 2007 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. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 18, 2007 Author Share Posted December 18, 2007 $_COOKIE['UserPosition'] Displayed my position Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 18, 2007 Author Share Posted December 18, 2007 Woah, turns out That I somehow deleted it, lol. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.