PHP调用MYSQL存储过程

WBOY
Release: 2016-06-13 13:36:45
Original
1007 people have browsed it

PHP调用MYSQL存储过程求助
错误信息:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\RUIOA\webroot\MyPHP\News\test.php on line 37


PHP:
$conn = mysqli_connect("localhost","root","chen");
mysqli_select_db($conn,"test");
$result = mysqli_query($conn,"call list();"); ==============>这里换成"select * from users;"就正常读出数据
while($row = mysqli_fetch_array($result)){
echo $row[1]."  ".$row[2]."  ".$row[2]."
";
}
?>

Mysql:
CREATE PROCEDURE list()
BEGIN
select * from users;
END;



mysqli与mysql都用过了,情况都是一样,用SQL语句就没问题,但是调用存储过程就不行

------解决方案--------------------

$result = mysqli_query('select * from users', $conn);//$conn是mysql_connect返回值(可有可无)
------解决方案--------------------
存储过程是什么意思...
------解决方案--------------------
还没用过存储过程这种高级东西
------解决方案--------------------
list是否没有在数据库test上面,我测试没问题
------解决方案--------------------
php调用MySQL存储过程方法集合~
传送门~

------解决方案--------------------
找一下rong framework,有Rong_Db_Driver_Mysqli::call($sql) 这个方法,是用来调用存储过程的。

------解决方案--------------------
错误提示$result必须是 mysql Resource 而你这返回的是boolean

你检查一下是不是语句定界符的错误
------解决方案--------------------

探讨

还有,补充一下如果是增删改的存储过程是能正常执行的,数据也正常改变,就是只要是返回SELECT的查询就会报错
PROCEDURE test.sel can't return a result set in the given context

------解决方案--------------------
你看看你的mysqli扩展打开没?
------解决方案--------------------
你在mysql编辑器里面,执行下存储过程看看,看可以执行不?然后在php调用试试
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!