gpt4 book ai didi

php - 通知: Array to string conversion in error when requesting data from a databse

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

我环顾四周,找不到问题的答案。我试图从数据库中获取一行,但它只是给了我一个通知:

注意:/xampp/... 中的数组到字符串转换

这是我的代码:

$sql6 = mysql_query("SELECT * FROM replies WHERE thread_id = $thread_id");
$numRows = mysql_num_rows($sql6);
$replies = '';
if ($numRows < 1) {
$replies = "There are no replies yet, you can make the first!";
} else {
while ($rows = mysql_fetch_array($sql6)) {
$reply_content = $rows[5];
$reply_username = $rows[7];
$reply_date = $rows[8];
$reply_author_id = [4];

$sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id");
$numRows = mysql_num_rows($sql);
if ($numRows < 1) {
while ($rows = mysql_fetch_array($sql)) {
$reply_user_fn = $rows['first_name'];
$reply_user_ln = $rows['last_name'];
$reply_user_id = $rows['id'];
$reply_user_pp = $rows['profile_pic'];
$reply_user_lvl = $rows['user_level'];
$reply_user_threads = $rows['threads'];
$reply_user_email = $rows['email'];


}
}
}
}

请帮助我。我对 PHP 还很陌生,我不知道我做错了什么。

最佳答案

错别字

 $sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id");
$numRows = mysql_num_rows($sql); //here $sql will be $sql9

------------------------------------------------------------ ^

 if ($numRows < 1) {
while ($rows = mysql_fetch_array($sql)) {//here $sql will be $sql9

------------------------------------------------------------ --------^

正确代码:

 $sql9 = mysql_query("SELECT * FROM users WHERE id = $reply_author_id");
$numRows = mysql_num_rows($sql9); //here $sql will be $sql9
if ($numRows < 1) {
while ($rows = mysql_fetch_array($sql9)) {//here $sql will be $sql9

关于php - 通知: Array to string conversion in error when requesting data from a databse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20673245/

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