所以,我试图更新我的表格 依据一个单数参数:
输入日期字段必须为空白 。
我想随机选择 50 行, 并更新空白所有者ID 字段到“ 测试者”
这就是我有的:
<?php
include("includes/constants.php");
include("includes/opendb.php");
$query = "SELECT * FROM contacts WHERE dateEntered= ORDER BY RAND() LIMIT 50";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$firstid = $row[ id ];
$query2 = mysql_query("UPDATE contacts
SET ownerID = Tester
WHERE id = $firstid ");
$result2 = mysql_query($query2) or die(mysql_error());
}
?>
它将更新一个记录,然后戒掉,给我:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 1 at line 1
选择记录的第一个部分效果很好,它的查询2不会更新所有50个记录,只有一个。也许我写错了。