我有一点问题这是我的代码`
if(isset($_POST['delete']))
{
$host="db1.xhost.ro"; // Host name
$username="supremesguild_01"; // Mysql username
$password="Blizzard951234"; // Mysql password
$db_name="supremesguild_xhost_ro01"; // Database name
$tbl_name="inventar"; // Table name
/*
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="acilogin"; // Database name
$tbl_name="inventar"; // Table name
*/
// Connect to server and select database.
$con = mysql_connect($host, $username, $password)or die("cannot connect");
// Get values from form
$id=$_POST['id'];
mysql_select_db($db_name, $con)or die("cannot select DB");
// modify data into mysql
$sql="DELETE FROM `$tbl_name` WHERE `ID` =$id LIMIT 1 ; ";
$auto = "SELECT MAX(`ID`) FROM `$tbl_name`";
ALTER TABLE $tbl_name AUTO_INCREMENT = $auto+1; //this is line 29
$result=mysql_query($sql, $con)or die('Could not delete data: ' . mysql_error());;
// if successfully insert data into database, displays message "Successful".
if($result){
header("Location:http://supremesguild.xhost.ro/index.php?pagina=delete_success");
}
else {
header("Location:http://supremesguild.xhost.ro/index.php?pagina=delete_failed");
}
mysql_close($con);
mysql_close();
}
我得到这个错误:解析错误:语法错误,第 29 行 /home/www/free/xhost.ro/supremesguild.xhost.ro/delete.php 中的意外 T_STRING。我试过:ALTER TABLE "$tbl_name" AUTO_INCREMENT = $auto+1;
或者
EXEC(ALTER TABLE $tbl_name AUTO_INCREMENT = $auto+1;)
但它说 exec 已经出于安全目的禁用我只想在每次删除后重置 AUTO_INCREMENT,有人可以帮助我吗?