2013-02-09 91 views
1
<?php 
session_start(); 
$host  = 'localhost'; 
$user  = 'root'; 
$password = '8******8'; 
$database = 'tg*****ba'; 

$conn = mysql_connect($host,$user,$password) or 
    die('Server Information is not Correct'); 

//Establish Connection with Server 
mysql_select_db($database,$conn) or die('Database Information is not correct'); 
$InGameName = mysql_real_escape_string($_POST['InGameName']); 
$LastVoteTime; 

//===When I will Set the Button to 1 or Press Button to register 
if(isset($_POST['btnVote'])) 
{ 
    if(md5($_POST['code']) != $_SESSION['key']) 
    die("You've entered a wrong code!"); 
    $query = mysql_query("SELECT * FROM entities WHERE Name = '". $InGameName ."'"); 
    if (mysql_num_rows($query) < 0) 
    { 
    die("This In game name doesn't exist , please enter your account name not username!"); 
    } 
    else 
    { 
    $date = date('YmdHis'); 
    $row=mysql_fetch_object($query); 
    $lastvote=$row->LastVoteTime; 
    $votingpoints = $row->VotsPoints; 
    $url = "http://www.xtremetop100.com/in.php?site=***********"; 

    if(($lastvote + 120000) < $date) 
    { 
     $lastvote = $date; 
     $votingpoints += 1; 
     $query = mysql_query("update entities set VotsPoints ='$votingpoints' set LastVoteTime ='$lastvote' WHERE Name = '". $InGameName ."'"); 
    } 
    else 
     die("You've Already voted in the last 12 hrs!"); 
    } 
} 

?> 

它不更新與votingpoints數據庫和lastvotetime 但它傳遞的第一次檢查(這意味着它發現在數據庫中的客戶記錄),但它不」簡單的PHP投票系統沒有更新數據庫

$query = mysql_query("update entities set VotsPoints = '$votingpoints', LastVoteTime = '$lastvote' WHERE Name = '". $InGameName ."'"); 

您使用「設置」多次,不知道這是OK:T將它們在代碼 感謝提前結束

+1

MySQL是depriciated ...轉移到PDO或mysqli的,請 – 2013-02-09 23:29:51

+2

謝謝你,但不會修復此代碼,我需要做的這個頁面儘快 – AndrewxXx 2013-02-09 23:31:15

+0

MySQL是不會被棄用。從PHP v5.5(目前僅在alpha版本中)開始,PHP擴展'ext/mysql'提供了前綴爲'mysql_'的所有函數。 – eggyal 2013-02-09 23:31:40

回答

2

嘗試。

+1

謝謝,那修復了這個問題,一旦時間限制超過了接受答案 – AndrewxXx 2013-02-09 23:35:56

+0

真棒,很高興幫助:D – span 2013-02-09 23:36:25