PHP脚本和MySQL的问题

时间:2018-03-13 14:00:32

标签: php mysql

我的PHP脚本存在问题。 我的脚本更新现有用户的值或添加它们。

但我想在“系统”和数据库中添加新变量“death”。

PHP / MySQL如何获取有关数据的信息? 这不是很重要,但这是脚本。

(这不是php,它的工作)

##脚本发送数据
        (player_get_unique_id, reg1, reg0),
    (player_get_gold, reg2, reg0),
    (player_get_death_count, reg3, reg0),
    (str_store_player_username, s0, reg0),
    (send_message_to_url, "@http://MyAwesomeIP/killrecord.php?unique%5Fid={reg1}&local%5Fid={reg0}&event=2&username={s0}&Gold={reg2}&death={reg3}"),

如您所见,我发送了4个变量。 (S0,REG0,REG1,REG2,REG3)

但目前我在php脚本/数据库中只使用了三个

(S0,REG0,REG1,REG2)

在我添加“死亡”表之前一切都很好

我只是将它添加到数据库,没有PHP编码等。

当我这样做时,新信息无法到达数据库。

但是当我再次删除“死亡”表格时,会再次出现新信息。

有人可以帮我解决这个问题吗? 我的PhP脚本从#### SEND DATA SCRIPT接收数据并将其发送到数据库。感谢您的任何建议!干杯Piter。

  #  killrecord.php
 <?php
 if(isset($_GET['event']) && isset($_GET['unique_id']) && 
 isset($_GET['local_id'])&& isset($_GET['username']))
{
  $unique_id=$_GET["unique_id"];
     $local_id=$_GET["local_id"];//for feedback only
     $username=$_GET["username"];

  $db_handle = mysqli_connect("localhost", "root", "mypassword", "dbname") 
or die("|-1");
  if($db_handle)
    if($_GET['event'] == 1)//get player gold
    {
      $sql_result = mysqli_query($db_handle, "SELECT Gold FROM tabelka WHERE 
Unique_Id = '$unique_id'" ); 
      $result = mysqli_fetch_row($sql_result); 

      if (!$result)
      {//the player is not in the database, so we will insert it
        mysqli_query($db_handle, "INSERT INTO tabelka 
(Unique_Id,Username,Gold VALUES($unique_id, '$username', 0)");
        echo "1|$unique_id|$local_id|0";//and we will echo gold as 0
      }else{
        echo "1|$unique_id|$local_id|1|".$result[0]; 
      }
    }else if($_GET['event'] == 2)//set player gold
    {
      if(isset($_GET['gold']))//if the gold is set
      {
        $gold = $_GET['gold'];
        mysqli_query($db_handle, "UPDATE tabelka SET Gold='$gold' WHERE 
 Unique_Id = '$unique_id'");
      }
    }
  mysqli_close($db_handle);
}

?>

如此简单。向我的表中添加新的“死亡”列会导致数据库无法创建/更新/接收新数据的问题。

0 个答案:

没有答案