构建并执行它,但phpmyadmin中的数据库没有任何更改...我遗漏了什么?
Active显然是每个表中的一个列名...我需要翻转107张桌子。
谢谢。
<?php
mysql_connect("localhost", "root", "789feRNSHB")or die("cannot connect to server");
mysql_select_db("core")or die("cannot select db");
$sql = "SHOW TABLES FROM core";
$result = mysql_query($sql);
$arrayCount = 0;
while($row = mysql_fetch_row($result)) {
$tableNames[$arrayCount] = $row[0];
$arrayCount++; //only do this to make sure it starts at index 0
}
//print_r($tableNames);
for($i=0;$i<sizeof($tableNames);$i++){
$table= $tableNames[$i];
echo $query = "UPDATE ".$table." SET Active=1 where Active=-1";
echo'>>'.mysql_query($query).'<br>';
}
?>发布于 2013-09-05 00:55:58
显式地调用mysql_error()函数来查看发生了什么。http://ca2.php.net/manual/en/function.mysql-error.php中的示例。
https://stackoverflow.com/questions/18604133
复制相似问题