我正在尝试调试我的代码,但mysql_error()没有显示任何内容.我知道有些不对劲,因为我写的时候
or die("ERROR");
它显示ERROR.所以问题必须是那一行代码.当我写作
or die(mysql_error());
它显示空白.这是我认为有错误的行的代码:
while ($rows = mysql_fetch_array($sql6) or die(mysql_error())) {
现在这里是完整的代码块:
$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) or die(mysql_error())) {
$reply_content = $rows['5'];
$reply_username = $rows['7'];
$reply_date = $rows['8'];
$reply_author_id = $rows['4'];
$sql9 = mysql_query("SELECT * FROM users WHERE id = '$reply_author_id'");
$numRows = mysql_num_rows($sql9);
if ($numRows < 1) {
while ($rows = mysql_fetch_array($sql9)) {
$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'];
$replies .= '
';$replies .= '
$replies .= '
Re: ' . $thread_title . '
';
$replies .= 'by: ' . $reply_username . ' - ' . $reply_date . '
';
$replies .= $reply_content;
$replies .= '
$replies .= '
$replies .= '
';
$replies .= ''. $reply_username .'
';
$replies .= '' . $reply_user_fn.' ' .$reply_user_ln . '
';
$replies .= 'Threads: ' . $reply_user_threads . '
Level: '. $reply_user_lvl .'
Sign up date: ' . $reply_user_email/*PUT SIGNUP DATE*/ .'';
$replies .= '';
$replies .= '
';}
}
}
}
我做错了什么,为什么PHP不显示mysql错误?
谢谢
解决方法:
不要在循环条件内放置或死亡().循环条件变为false表示循环结束,并且每次循环完成时也会触发die().
mysql_fetch_row()在没有更多行时返回false,这是触发你的die()语句的内容,尽管没有错误.
标签:php,mysql,syntax-error,mysql-error-1064
来源: https://codeday.me/bug/20190517/1120791.html