我使用phpMyadmin作为数据库,我不能删除表格...如何发现语法错误?
<?php
include 'dbconnect.php'; //connect to DB
//Droping The tables
$dropping = @mysql_query('DROP TABLE IF EXISTS rents, criticise, writesIn, writenIn, translated, reads, worksIn, inStock, playsIN, store, genre, employee, newspaper, customer, critic, language, actor, film, city ;');
if (!$dropping) {
exit('<p>Error dropping the tables<br />'.
'Error: ' . mysql_error() . '</p>');
}
if ($dropping) {
echo 'everything went just fine dropping the tables<br>';
}
答案 0 :(得分:1)
reads
是reserved MySQL keyword。你需要将它包含在反引号中:
DROP TABLE IF EXISTS rents, criticise, writesIn, writenIn, translated, `reads`, worksIn, inStock, playsIN, store, genre, employee, newspaper, customer, critic, language, actor, film, city
答案 1 :(得分:0)
$dropping = @mysql_query('DROP TABLE IF EXISTS rents, criticise, writesIn, writenIn, translated, `reads`, worksIn, inStock, playsIN, store, genre, employee, newspaper, customer, critic, language, actor, film, city ');
删除分号;
并使用reads
的反引号作为关键字