2013-03-07 45 views
-2

我有一些錯誤,md100sms.php沒有在硬幣列添加硬幣數據庫MySQL查詢錯誤 - 自動硬幣ADD

<?PHP 
    if(isset($_GET['do']) && $_GET['do']=="aktivieren" && isset($_GET['hash']) && !empty($_GET['hash'])) { 
    echo '<div class="main main_top"> 
    Information 
</div> 
<div class="main main_content">'; 
    if(strlen($_GET['hash'])==32 && $_GET['hash']!=1 && checkAnum($_GET['hash'])) { 
     $cmdHash = "SELECT id,web_aktiviert FROM account.account WHERE web_aktiviert='".$_GET['hash']."' AND web_aktiviert!='1' LIMIT 1;"; 
     $qryHash = mysql_query($cmdHash,$sqlServ); 

     if(mysql_num_rows($qryHash)) { 

     $getData = mysql_fetch_object($qryHash); 
     $userUpdate = "UPDATE account.account SET web_aktiviert='1',status='OK' WHERE id='".$getData->id."' LIMIT 1;"; 
     $updateQry = mysql_query($userUpdate,$sqlServ); 

     if($updateQry) { 
      echo'Ihr Account wurde erfolgreich aktiviert. Sie k&ouml;nnen sich nun einloggen.'; 
      echo'<meta http-equiv="refresh" content="1; URL=index.php?s=login"> '; 
     } 
     else { 
      echo'Query fehlgeschlagen. Bitte einen Admin kontaktieren!'; 
     } 

     } 
     else { 
     echo'Es wurde kein passender Eintrag gefunden. Aktivierung fehlgeschlagen.'; 
     } 

    } 
    else { 
     echo'Kein valider Hash!'; 
    } 
    echo '</div> 
<div class="main main_bottom"> 
</div>'; 
    } 

    if(!empty($_SESSION['user_id'])) 
    { 
    echo '<div id="con-top" class="post-top1">Login</div> 
<div id="con-mid"> 
    '; 
    echo'<ul style="margin-top:0;">'; 
    if($_SESSION['user_admin']>0) { 
     echo'<li><a href="index.php?s=admin">Administrar</a></li>'; 
    } 
    if($_SESSION['user_admin']>=0) { 
     echo'<a href="index.php?s=itemshop"><input type="submit" class="btn" value="ItemShop" name="submit"></a>&nbsp;&nbsp;'; 
     echo'<a href="index.php?s=spenden"><input type="submit" class="btn" value="Comprar Moedas" name="submit"></a>&nbsp;&nbsp;'; 
     echo'<a href="index.php?s=charaktere"><input type="submit" class="btn" value="Personagens" name="submit"></a>&nbsp;&nbsp;'; 
     echo'<a href="index.php?s=passwort"><input type="submit" class="btn" value="Alterar Dados" name="submit"></a>&nbsp;&nbsp;'; 
     echo'<a href="index.php?s=Vote"><input type="submit" class="btn" value="Votar no Servidor" name="submit"></a>&nbsp;&nbsp;'; 
    }  
    $cmdStats = "SELECT SUM(player.playtime) AS ges_spielzeit, COUNT(*) AS ges_chars, player_index.empire 
    FROM player.player 
    INNER JOIN player.player_index ON player_index.id = player.account_id 
    WHERE player.account_id = '".$_SESSION['user_id']."' 
    LIMIT 1"; 

    $qryStats = mysql_query($cmdStats,$sqlServ); 
    $getStats = mysql_fetch_object($qryStats); 

    if(!empty($getStats->empire)) { 
     $reich = '<img src="img/reiche/'.$getStats->empire.'.png" title="Reino" alt="Reino"/>'; 
    } 
    else { 
     $reich='Conta sem reino.'; 
    } 


    echo'<table> 
     <tr> 
     <th class="topLine">ID:</th> 
     <td class="tdunkel">'.$_SESSION['user_name'].'</td> 
     </tr> 
     <tr> 
     <th class="topLine">Reino:</th> 
     <td class="thell">'.$reich.'</td> 
     </tr> 
     <tr> 
     <th class="topLine">Personagens:</th> 
     <td class="tdunkel">'.$getStats->ges_chars.'</td> 
     </tr> 
     <tr> 
     <th class="topLine">Tempo de Jogo:</th> 
     <td class="thell">'.$getStats->ges_spielzeit.' Minutos</td> 
     </tr>'; 
    $sqlAcc = "SELECT account.social_id AS loeschcode, safebox.password AS lagerpw 
    FROM account.account 
    LEFT JOIN player.safebox 
    ON account.id=safebox.account_id 
    WHERE account.id='".$_SESSION['user_id']."'"; 

    $qryAcc = mysql_query($sqlAcc) or die(mysql_error()); 
    $getAcc = mysql_fetch_object($qryAcc); 

    if(empty($getAcc->lagerpw)) $getAcc->lagerpw = '000000'; 

     echo'<tr style="margin-bottom:0;"> 
     <th class="topLine">Codigo Personagem:</th> 
     <td class="tdunkel">'.$getAcc->loeschcode.'</td> 
     </tr> 
    </table> 
</div> 
<div id="con-bot"></div> </div>'; 
    } 
    else 
    { 
    ?> 
<div id="con-top" class="post-top1">Entrar</div> 
<div id="con-mid"> 
<form action="index.php?s=login" method="POST" class="login"> 
     <input type="text" class="bar" name="userid" onFocus="if(this.value=='Oseuid') this.value=''" onBlur="if(this.value=='')this.value='Oseuid'" value="Oseuid"> 
     <input type="password" class="bar" name="userpass" onFocus="if(this.value=='Passwortpasswort') this.value=''" onBlur="if(this.value=='')this.value='Passwortpasswort'" value="Passwortpasswort"> 
     <input type="submit" class="btn" value="LOGIN" name="submit"> 
     <span><br> 
     <a href="index.php?s=register">Criar um nova conta!</a><br /> 
     <a href="index.php?s=lostpw">Esqueceste a senha?</a> 
     </span> 
    </form> 
</div> 
<div id="con-bot"></div> </div> 
    <?PHP 
    } 
?> 

md100sms.php

<div id="con-top" class="post-top1">Moedas Automaticas - 100 Moedas</div> 
<div id="con-mid"> 

<font color="green">Moedas compradas com sucesso.<br> 
Foram adicionadas <font color="white">100</font> Moedas à tua conta.</font> 
<?PHP 
      $sqlCmd = sprintf("UPDATE account.account SET coins = coins +100 WHERE id = '.$_SESSION['user_id'].'") 
    ?> 

</div> 
<div id="con-bot"></div></div> 

當我去md100sms.php,頁面上說:Successful added coins, 100 coins.

但是當我去看我的帳戶數據庫它繼續使用相同的硬幣。

+0

你爲什麼使用sprintf? – Oli 2013-03-07 14:19:44

+0

我刪除sprintf,並給我同樣的錯誤。 – AMS 2013-03-07 14:20:57

+0

你確定'$ _SESSION ['user_id']'被填充了嗎?在你的文件的頂部,你是否帶着'session_start();'? – 2013-03-07 14:32:52

回答

0

這裏有引號的問題。更改

$sqlCmd = sprintf("UPDATE account.account SET coins = coins +100 WHERE id = '.$_SESSION['user_id'].'" 

$sqlCmd = "UPDATE account.account SET coins = coins +100 WHERE id = '".$_SESSION['user_id']."'" 
+0

現在顯示消息:Moedas compradas com sucesso。但不要添加硬幣。 :( – AMS 2013-03-07 14:25:06

+0

@AMS,這裏沒有顯示,你是否真的執行了查詢,如果是這樣,你怎麼做?你可能想用這些細節更新你的問題。 – Fabien 2013-03-07 14:32:59

+0

我更新了這個問題! – AMS 2013-03-07 14:36:37

0

你混淆了你的報價一點點。試試這個:

$sqlCmd = sprintf("UPDATE account.account SET coins = coins +100 WHERE id = '" . $_SESSION['user_id'] . "'"); 
+0

現在顯示消息:Moedas compradas com 但是不要加硬幣。:( – AMS 2013-03-07 14:23:05

0

替換:

$sqlCmd = sprintf("UPDATE account.account SET coins = coins +100 WHERE id = '.$_SESSION['user_id'].'") 

有: -

$sqlCmd = sprintf("UPDATE account.account SET coins = coins +100 WHERE id = '{$_SESSION['user_id']}'"); 

(我已經把分號在該行的結束和糾正各地會話語法變量)。

+0

現在顯示消息:Moedas compradas com sucesso。但不要添加硬幣。 :( – AMS 2013-03-07 14:26:54

+0

我更新了問題! – AMS 2013-03-07 14:35:25

0

嘗試將session_start();添加到頁面的頂部。

此外,請檢查您的詢問報價。嘗試:

$sqlCmd = sprintf("UPDATE account.account SET coins = coins + 100 WHERE id = '".$_SESSION['user_id']."'");