简体   繁体   English

这个sql有什么问题吗?

[英]Is there anything wrong with this sql?

I'm trying to insert values into my notifications table. 我正在尝试将值插入到通知表中。 In the PHP file, everything works perfectly fine except when I check my database in PHPmyAdmin, the values are not inserted and they are not there. 在PHP文件中,一切正常,除非当我在PHPmyAdmin中检查数据库时,未插入值且它们不存在。 Can someone please tell me if there's anything wrong with this? 有人可以告诉我这有什么问题吗?

mysqli_query($db_conx, "INSERT INTO notifications(username, initiator, app, note, date_time) 
                 VALUES('$user','anonymous','$app','$note',now())");

By seeing this much code two suggestion for you:- 通过看到这么多的代码,两个建议给您:

  1. add error reporting code on top of your page just after <?php . <?php之后,在页面顶部添加错误报告代码。 Add these lines:- 添加这些行:

    error_reporting(E_ALL); ini_set('display_errors',1);

  2. Change your query like below:- 如下更改查询:

    mysqli_query($db_conx, "INSERT INTO notifications(username, initiator, app, note, date_time) VALUES('".$user."','anonymous','".$app."','".$note."','".now()."')") or die(mysqli_error($db_conx));

Note:- This will provide you details about what exact error occur in your code.Thanks. 注意:-这将为您提供有关代码中发生的确切错误的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM