我一直在测试我的SQL在phpmyadmin,我知道SQL工作正常,但当我通过表单按钮调用它时,它什么都不做。任何人都可以告诉我我做错了什么。使用PHP更新MySQL记录 - SQL的作品,PHP方面不
这是在主窗体页面中的PHP:
<?php
echo
"<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
<th>health</th>
<th>damage</th>
</tr>";
while($row = mysql_fetch_row($result)) {
echo '<tr>';
foreach($row as $cell) {
echo "\n<td>$cell</td>";
}
echo '<td><form method="POST" action="attack.php">
<input name="update" type="button" value="Update Record" />
<input type="hidden" name="'.$row[1].'" /></form></td></tr>';
echo "\n\n";
echo "test";
}
?>
<?php
require_once('config.php');
$sqltest = $sqltest - 5;
$id = floor($_GET['id']);
if($id > 0)
{
$sql1="UPDATE ajax_demo SET Health = Health - Damage";
$result=mysql_query($sql1);
mysql_close();
}
?>
obvisouly我想补充的可变因素NITO SQL字符串但是出于测试目的,我离开了它本身。如果任何人都可以提供帮助,那么它将会受到很大的困扰。
$ SQL1 = “UPDATE ajax_demo SET健康=健康 - 伤害'”; 改变这一点。 – Dgo 2013-02-21 11:15:07
1)当你用HTML注入时,你不会转义数值。 2)你不检查'mysql_query()'是否成功。 3)您正在使用已弃用的扩展名。 – 2013-02-21 11:18:55
ÁlvaroG. Vicario可以延长这些点吗? – user1284386 2013-02-21 11:31:16