我正在尝试调试我的代码,但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 .= '
'; $replies .= 'by: ' . $reply_username . ' - ' . $reply_date . '
'; $replies .= $reply_content; $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错误?谢谢
1 个回答
不要放在
or die()
循环条件内.循环条件变为false
表示循环结束的信号,并且die()
每次循环完成时也会触发.
mysql_fetch_row()
当没有更多行时返回false这是触发您的die()
语句的内容,尽管没有错误.2023-02-09 09:03 回答唐吉诃德撰写答案今天,你开发时遇到什么问题呢?立即提问PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有