Waleed2 Posted March 12, 2013 Share Posted March 12, 2013 (edited) I have an private server.I am making an vote script so if you vote for my private server it adds one point.The script works but it doesn't show in game.I think it doesn't show in game because the column that script edits is an int value.I think it updates it as a text value so it doesn't works.Can you recommend me anything.Please help me.I will appreciate all answers. <?php mysql_connect("localhost", "root", "your_password"); mysql_select_db("db_game"); $timeout=60*60*12; $time=time(); $out=$time-$timeout; $username=$_POST['username']; $points1=mysql_query("SELECT pvpscore FROM t_user WHERE name='$username'"); while($row = mysql_fetch_array( $points1 )) { $points=$row['pvpscore']+1;} $check_double=mysql_query("SELECT * FROM t_account WHERE name='$username' AND time>$out")or die(mysql_error()); if(mysql_num_rows($check_double)>0){ echo "You already voted. You can vote each 12 hours"; } else{ header("location:Vote Link"); $vote=mysql_query("UPDATE t_user SET time='$time', pvpscore='$points' WHERE name='$username'");} ?> Note:Time is a text field and pvpscore is a int(11) field. Edited March 12, 2013 by Waleed2 Quote Link to comment https://forums.phpfreaks.com/topic/275537-help-with-vote-script/ Share on other sites More sharing options...
DaveyK Posted March 12, 2013 Share Posted March 12, 2013 Header('Location'); redirects the user, so the (update) query right after the header() wont even run... Quote Link to comment https://forums.phpfreaks.com/topic/275537-help-with-vote-script/#findComment-1418133 Share on other sites More sharing options...
Waleed2 Posted March 12, 2013 Author Share Posted March 12, 2013 It works it adds 1 more points but it updates it as a text value.how to update it as an int value? Quote Link to comment https://forums.phpfreaks.com/topic/275537-help-with-vote-script/#findComment-1418135 Share on other sites More sharing options...
Waleed2 Posted March 12, 2013 Author Share Posted March 12, 2013 anyone help me please Quote Link to comment https://forums.phpfreaks.com/topic/275537-help-with-vote-script/#findComment-1418137 Share on other sites More sharing options...
yomanny Posted March 12, 2013 Share Posted March 12, 2013 You're saying your time column is a text field, but it should really be an int since you're using it like this in your query: $check_double=mysql_query("SELECT * FROM t_account WHERE name='$username' AND time>$out")or die(mysql_error()); See the bold? You're trying to ask "Is this text larger than this int" So try set the text column in the database to int and see if that solves your problem! ..and just like DaveyK said, remove the header("location:Vote Link"); or at least move it. - W Quote Link to comment https://forums.phpfreaks.com/topic/275537-help-with-vote-script/#findComment-1418216 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.