Mysqli_error()不起作用 [英] Mysqli_error() does not work

查看:73
本文介绍了Mysqli_error()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码:

  $dbc = mysqli_connect("localhost","root","root","magnificantDatabase")
  or die("Could not connect to database");

  $sql = "INSERT INTO accounts(username, password, ip)
  VALUES('$username','$password','$ip')";

  mysqli_query($dbc, $sql)
  or die(mysqli_error($dbc));

当mysqli_query失败时应该返回一个错误,不是吗? 虽然不是:/ 任何人都知道为什么不这样做吗?

Should return an error when the mysqli_query fails return an error, shouldn't it? It doesn't though :/ Anyone have any ideas why it doesn't?

哦,通过不返回错误,我的意思是它什么也不返回. 只是完全空白.

Oh and, by returning no error I mean it returns nothing at all. just completely blank.

我想告诉您,在网上搜索后(尽管这似乎是一个常见问题),但我没有找到解决此问题的任何方法,但是有一些与此问题相关的问题,但是我没有发现它们完全相同.

I'd like to let you know that after having searched the web (even though as this would seem a common problem) I have -NOT- found anything that fixes this, there are issues close to this one, but none of them I have found appear to be the exact same.

推荐答案

我执行UPDATE语句时发生了同样的事情.

Same thing happened to me when I executed an UPDATE statement.

mysqli_error,mysqli_errno和mysqli_error_list全部为空.

mysqli_error, mysqli_errno and mysqli_error_list were all empty.

然后我发现问题是分配给连接对象的数据库用户没有UPDATE特权.我不知道为什么我没有收到此安全/特权违规的错误消息或错误号.

Then I discovered that the problem was that the database user assigned to the connection object did not have the UPDATE privilege. I don't know why I did not receive an error message or an error number for this security/privilege breach.

这篇关于Mysqli_error()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆