Jump to content

Help with vote script


Waleed2

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/275537-help-with-vote-script/
Share on other sites

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

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.