gpt4 book ai didi

php - 将 MySQL 过程结果设置为 PHP 变量

转载 作者:太空宇宙 更新时间:2023-11-03 12:34:42 25 4
gpt4 key购买 nike

我试图将此 MySQL 存储过程的两个输出设置为 PHP 变量:

$result = mysql_query("CALL mst2('$q', @eset, @leng)");
if (!$result) {
die('Invalid query: ' . mysql_error());
}

while($row = @mysql_fetch_assoc($result))
{
debug($row);

}
$eset = $row->{'@eset'};
$length= $row->{'@leng'};

最后两行抛出错误 Trying to get property of non-object 。有人知道这样做的正确方法吗?

最佳答案

mysql_fetch_object 而不是 mysql_fetch_assoc 应该可以修复您的查询。

其次,尽管您真的应该考虑使用 mysqli_ 或 pdo 语句。

链接在这里:

关于php - 将 MySQL 过程结果设置为 PHP 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13735195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com