本文介绍了MySQL查询错误-自动硬币添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一些错误,md100sms.php未在硬币列中将硬币添加到数据库中

<?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.

When I go to md100sms.php, the page says: Successful added coins, 100 coins.

但是当我去数据库中查看我的帐户时,它会继续使用相同的硬币.

But when I go to see my account on the database it continues with the same coins.

推荐答案

尝试将session_start();添加到页面顶部.

Try adding session_start(); to the top of your pages.

此外,请检查查询中的引号.试试:

Also, check your quotes on the query. Try:

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

这篇关于MySQL查询错误-自动硬币添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 10:28