![](/img/trans.png)
[英]Why is this ALTER TABLE MYSQL query not executing(returning false)? The syntax appears correct
[英]what is the correct syntax for MySQL alter table query?
当我尝试运行以下mysqli调用时
$strSQL3=mysqli_query($connection," alter table mark_list add column 'mark' int(2) " ) or die(mysqli_error($connection));
返回错误
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 `mark int(2)` at line 1
单引号( '
)表示字符串文字。 对象名称(例如列)不是字符串-突出号将引起引号:
$strSQL3 = mysqli_query($connection ,"alter table mark_list add column mark int(2)" ) or die(mysqli_error($connection));
尝试更改“标记”以这样标记 :
$strSQL3=mysqli_query($connection,
" alter table mark_list add column mark int(2) " )
or die(mysqli_error($connection));
只需删除'
标记附近的引号
$strSQL3=mysqli_query($connection," alter table mark_list add column mark int(2) " ) or die(mysqli_error($connection));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.