且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从PHP代码中调用MySQL存储过程?

更新时间:2022-11-25 15:04:21

我现在通过使用mysqli而不是mysql找到了解决方案.

I now found solution by using mysqli instead of mysql.

<?php 

// enable error reporting
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
//connect to database
$connection = mysqli_connect("hostname", "user", "password", "db", "port");

//run the store proc
$result = mysqli_query($connection, "CALL StoreProcName");

//loop the result set
while ($row = mysqli_fetch_array($result)){     
  echo $row[0] . " - " . + $row[1]; 
}

我发现许多人似乎在使用mysql_connect, mysql_query and mysql_fetch_array时遇到问题.

I found that many people seem to have a problem with using mysql_connect, mysql_query and mysql_fetch_array.