当前位置:Gxlcms > PHP教程 > PHPmysql_query()执行存储过程报错喽

PHPmysql_query()执行存储过程报错喽

时间:2021-07-01 10:21:17 帮助过:15人阅读

第一种方式:
$data = mysql_query("CALL DB.Query('11',‘S’)");
if(!$data){
dump(mysql_error());
}
这种方式查询正常,没问题!

第二种方式:
$data = mysql_query("SET @A = '11',@B='S'; CALL DB.Query(@A,@B);");
if(!$data){
dump(mysql_error());
}
这样就报错了
"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 'CALL bi.gm_queryRoleLoginLogOutLog(@A,@B); ' at line 1"

就想知道啥原因,麻烦啦


回复讨论(解决方案)

SET @A = '11',@B='S';这个是存储过程里的写法吧,
mysql_query里面你就写单纯的SQL语句

@tata8181
大哥 在调用存储过程写SQL的时候这种写法是没问题的

mysql_query 一次只能执行一条指令
请改用 mysqli_multi_query

感谢版主

人气教程排行