php mysql 显示错误日志,php – mysql_error()没有显示错误

我正在尝试调试我的代码,但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 .= ''%20.%20%24reply_user_pp%20.%20'
';

$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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值