0

当サイトでは、複数のアカウントを持ち、それぞれにポイントが貯まるシステムを導入しています。エラーに気付いたこのウェブページのアカウント間で移行できるポイント。基本的に、口座の組み合わせが1番と2番の場合、「番号を記入してください」とだけ言われて振込みができません。1 番目と 3 番目、または 3 つすべてがあれば、問題なく動作します。私は約2時間それを調べてきましたが、何が機能していないのかを見つけることができません...どんな助けも非常に高く評価されます:D

  <?php if($a == "exchange")

  {
  $GetUserInfo = mysql_query("SELECT * FROM members WHERE id = '$userid'") or die(mysql_error());

    $GetUserInfo = mysql_fetch_object($GetUserInfo);

    $cols = 1; //determines colspan
    $status = 1;

    $GetMultipleInfo = mysql_query("SELECT * FROM members WHERE id = '".$GetUserInfo->mult_uid."'") or die(mysql_error());  
      if(mysql_num_rows($GetMultipleInfo) != 0)
      {
        ++$cols;
        ++$status;
      }
      $GetMultipleInfo = mysql_fetch_object($GetMultipleInfo);



    $GetAdMultipleInfo = mysql_query("SELECT * FROM members WHERE id = '".$GetUserInfo->mult_admin."'") or die(mysql_error());
      if(mysql_num_rows($GetAdMultipleInfo) != 0)
      {
        ++$cols;
        $status = ($status == 2 ? 4 : 3);
      }
      $GetAdMultipleInfo = mysql_fetch_object($GetAdMultipleInfo);


// Sparks Transfer
if (isset($_POST['spartrans']))
{
  $order = $_POST['sparrecipients'];

if ($order == 'first')
{
  $tpoints2 = $_POST['tpoints2'];
  $tpoints3 = $_POST['tpoints3'];
  $tpoints = $tpoints2 + $tpoints3;

   if ($status == 2)
      if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints2)) || empty($tpoints1) ||  empty($tpoints2))
        message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");
  elseif ($status == 3)
      if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints3)) || empty($tpoints1) || empty($tpoints3))
        message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");
  elseif ($status == 4)
      if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints2)) || (!is_numeric($tpoints3)) || empty($tpoints1)  ||  empty($tpoints2) || empty($tpoints3))
        message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

  if ($tpoints2 > $GetMultipleInfo->tpoints)
    message("" . getName($GetMultipleInfo->id) . " does not have enough sparks.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

  if ($tpoints3 > $GetAdMultipleInfo->tpoints)
    message("" . getName($GetAdMultipleInfo->id) . " does not have enough sparks.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

  if ($GetUserInfo->mult_uid != 0)
    mysql_query("UPDATE members SET tpoints = GREATEST(tpoints - $tpoints2,0) WHERE id = '".$GetMultipleInfo->id."'") or die(mysql_error());
  if ($GetUserInfo->mult_admin != 0)
    mysql_query("UPDATE members SET tpoints = GREATEST(tpoints - $tpoints3,0) WHERE id = '".$GetAdMultipleInfo->id."'") or die(mysql_error());
  mysql_query("UPDATE members SET tpoints = GREATEST(tpoints + $tpoints,0) WHERE id = '$userid'") or die(mysql_error());

  message("Successfully transferred $tpoints Sparks to ".getName($userid).".","Enchanted Hogwarts","$PHP_SELF?a=exchange");
}

}

}
?>
4

1 に答える 1

0

ここのコードでは、いくつかの変数を確立しています。

if ($order == 'first')
{
    $tpoints2 = $_POST['tpoints2'];
    $tpoints3 = $_POST['tpoints3'];
    $tpoints = $tpoints2 + $tpoints3;

しかし、ここではさまざまな変数の値をチェックしています。 $tpoints1は確立されませんでした。

if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints2)) || empty($tpoints1) ||  empty($tpoints2))
          message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

編集:それはおそらく正しくありません。おそらく、その変数を自動的に設定する register_globals があります。推奨されませんが、あなたが尋ねた質問ではありません。

要するに、コードのどのブランチが実行されているかを把握する必要があります。あなたの説明に基づく私の推測では、それは$order == 最初のブランチであり、次に$status == 3です。しかし、実際にフォームを送信し、どの選択が行われたかを知らなければ、私には判断できません。そして、エラーメッセージはどれも同じ「数字で入力してください」ということ。あまり役に立ちません。

私は個人的にあなたのコードの一部をリファクタリングするためにこの時間を取ります. わからないことがあれば、わかるまで細かく分割します。そうしないと、何か問題が発生するたびに、このページを調べて解決しようとすることになります。

$order を選択するたびに、$tpoints1、$tpoints2、および $tpoints3 の値がまったく同じ方法で検証されます。それを関数に移動することから始めて、そこから始めます。

于 2012-08-21T02:45:53.833 に答える