gpt4 book ai didi

PHP\MySql 查询错误

转载 作者:行者123 更新时间:2023-11-30 00:19:03 24 4
gpt4 key购买 nike

我的网络服务器上的 php 页面出现问题:

Warning: Invalid argument supplied for foreach() in /home/vyhtpnwt/public_html/include/main.php on line 12

页面第12行是:

foreach ($conn->query("SELECT * FROM accountType WHERE id=".$accountTypeID) as $row2) {
$accountType = $row2[$lang['dbLabel']];
if ($row2['expirationDays']==999) {$accountExp = $lang['unlimitedExp'];} else {
//expiration date script!
$accountExp = 0;
}

考虑到:

  • $conn 在其他脚本上正常工作;

  • $accountTypeID 已填充且 = 1;

  • 他的 SELECT 返回 1 个结果;

  • 字段expirationDays

  • $lang['dbLabel'] 和 $lang['unlimitedExp'] 已正确填充。

可能是什么问题?

预先感谢您的宝贵帮助!!!

最佳答案

你应该尝试这个:

$q = $conn->query
("SELECT * FROM
accountType WHERE id=".
$accountTypeID);
$ar = $q->fetch_assoc():

foreach( $ar as $row2)
{
// your code here
}

因为您实际上没有从该代码中获取数组,所以您只是获取了 mysqli_query 对象本身,这不是您想要/需要的值数组

关于PHP\MySql 查询错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23396101/

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