我正在努力使登录用户在框中输入一个值,然后提交它并将表单存储在“money”下的数据库中。 但是,当我尝试这样做时,我得到错误:表'servername.array'不存在。我知道服务器(蓝色)和表(播放器)存在,无法弄清楚为什么我收到此错误。用户使用$ _SESSION ['username']和$ _SESSION ['id']登录。
<?php include("auth.php");?>
<?php
if(isset($_POST['submit']))
{
$player = @mysql_query
("SELECT id, username, password, registered, lastlogin, money,
callname, email FROM players WHERE username =
'".$_SESSION['username']."'");
$player = @mysql_fetch_assoc($player);
$getmoney = @mysql_query("INSERT INTO $player(money) values('$_POST[amount]')")
or die("Error: ".mysql_error());
echo '
<div style="
top: 395;
left: 99;
position: absolute;
z-index: 1;
visibility: show;">
Money Received.
</div>
';
}
?>
</head>
<body>
<p>Bank</p>
Enter amount of money to recieve.<br>
<form action="bank.php" method="post">
<table border=2>
<tr>
<td>Amount to Receive:</td><td><input type="text" name="amount" size="20px"></input>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Get Money"></input>
</form><br><br>
答案 0 :(得分:0)
将行更改为此行:不使用$ player变量(这是上一个查询中的数组)
$getmoney = @mysql_query("INSERT INTO players(money) values('$_POST[amount]')")
or die("Error: ".mysql_error());