Keeping track of voting There is HTML that triggers the code below I want to disallow executing the script more than once per 24 hours. I wanted this script to store the last visit time in a table against the user ID in a database, then do a time calculation and back them out until the 24 hour expiry time.

&lt;?php
//Input correct values into this section
$dbhost = '888888';
$dbuser = '888888';
$dbpass = '888888';
$dbname = '888888';
$dbtable = 'redeem';
$dbtable2 = 'playersthatvoted';
//------------------------------------
$input = 'diamond 12';
$player = $_POST['Player'];
$time = time();
if(!isset($_COOKIE['24Hourvote'])){
   //---- This is the connection
   $conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('Error: ' . mysql_error());
   mysql_select_db($dbname);
   $query1 = "INSERT INTO `".$dbname."`.`".$dbtable."` (`player`, `item`) VALUES ('".$player."', '".$input."')";
   $query2 = "INSERT INTO `".$dbname."`.`".$dbtable2."` (`player`, `time`) VALUES ('".$player."', '".$time."')";
   mysql_query($query1);
   mysql_query($query2);
   $query= 'SELECT `player` FROM `playersthatvoted` ASC LIMIT 0, 10 ';
   $result = mysql_query($query);
   mysql_close($conn);
   echo 'Done! Type /redeem in-game to get your diamonds.';
   $ip=@$REMOTE_ADDR;
   setcookie ("24Hourvote",$ip,time()+86400,'/',true,…
} else {
   echo 'You have already voted today! Come back later...'; }
?&gt;
Note: this is intended to be a Community wiki since it was taken from a deleted answer by yannis; The suggestion to do this was here

mysql_* functions
Stop using them, immediately! They are essentially deprecated, as they refer to MySQL before version 4.1. They are not removed as to not brake backward compatibility, but there's no point in using them.
The drop in replacement is myslqi_* functions, which are based around a newer MySQL driver that works better with MySQL 5.x. You can easily replace most references to myslq_* functions by just adding the extra i.
But a far better solution is PDO, an object oriented database agnostic interface. Since you are starting out in object oriented PHP you'll definitely appreciate the object orient part, and as for the database agnostic part, it means that you can easily switch databases (with minor modifications).
Verbatim copy from another one of my reviews.
Long if, small else
Instead of:
if( condition ) {
    // blah
    // blah 
    // blah
    // blah
    // blah
    // blah
    // blah
    // blah
    // blah
} else {
    // blah
}

consider refactoring as:
if( !condition ) {
    // blah    
    exit();
} 

// blah
// blah
// blah

It's a bit more readable.
Player, you've been played
You get $player from a post variable:
$player = $_POST['Player'];

and then you go and feed it to the database:
$query1 = &quot;INSERT INTO `&quot;.$dbname.&quot;`.`&quot;.$dbtable.&quot;` (`player`, `item`) VALUES ('&quot;.$player.&quot;', '&quot;.$input.&quot;')&quot;;

and, sooner or later, you're dead. Read everything you can about SQL injection on Wikipedia and the manual. Tips:

User input is unsafe, and it includes everything that comes from the environment ($_POST, $_GET, $_SESSION, $_COOKIE, $_SERVER, etc).
Always validate and sanitize user input. Not only when you feed it to a database, always.

For this instance, your best bet would be to go with PDO and prepared statements, that's how the cool kids do it anyway. Additionally, use the Filter extension.
Error suppression operator
$ip=@$REMOTE_ADDR;

First of all, where does $REMOTE_ADDR come from and why do you suppress errors? What exactly are you doing there and what can go wrong.
In any case, forget all about the error suppression operator, it's evil and it must die.