日期:2014-05-17  浏览次数:20486 次

大家看看我这句话那里出错了?
mysql_query("DROP PROCEDURE IF EXISTS change",$con) or die("出错了:".mysql_error());

最近在学习存储过程的事情,用 PHP 添加和删除存储过程。


错误提示为:

出错了: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 'change' at line 1

搞不懂,即使更简单一些,变成 

mysql_query("DROP PROCEDURE IF EXISTS change") or die("出错了:".mysql_error());

也不行。。。。

但是,如果我将后面的一句 or die("出错了:".mysql_error()) 删除掉,程序又不报错。。。

为什么啊

------解决方案--------------------
change 是 mysql 保留字,需转义
mysql_query("DROP PROCEDURE IF EXISTS `change`",$con) or die("出错了:".mysql_error());