简体   繁体   English

SQL PHP没有插入数据库

[英]SQL PHP not inserting into database

for some reason, my stuff isn't inserting into my database, and I've overlooked it a plethora of times.. 由于某种原因,我的东西没有插入我的数据库,我已经多次忽略了它..

AJAX Handler: AJAX处理程序:

<?php
require_once('../../blog/inc/config.php');

$form_name = htmlspecialchars($_GET['form_name']);
$form_commentid = $_GET['form_commentid'];
$date = date('M jS Y | g:i a T');
$ip = $_SERVER['REMOTE_ADDR'];

 if($form_name == '') {
    echo("Name");

} else if($form_commentid == '') {
    echo("Comment ID");

} else {
mysql_query("INSERT INTO reportcomment (id, name, commentid, date, ip) VALUES     (NULL,'{$_GET['id']}','{$form_name}','{$form_commentid}','{$date}','{$ip}')");

    // output comment
    echo "success brah";
}
?>

Reporting.php file: Reporting.php文件:

<script type="text/javascript">
$(function() {

 $('#reset_form').click(function() {
 $('#name,#commentid').val('');
 });
 $('#submit').click(function() {

var name = $('#name').val();
var commentid = $('#commentid').val();

$.ajax({
url: '../../_lib/forms/report_ajax.php?id=<?php echo $_GET['id']; ?>',
data: { form_name: name, form_commentid: commentid },
success: function(data) {
    $('#report_comment').append(data);
    $(document).trigger('close.facebox');
}
});
});
});
</script>


      Name: <br />
      <input type="text" id="name" class="userpass"/>

      <input  type="text" id="commentid" class="userpass""/>


      <input type="submit" id="submit" value="Report" class="button" />
  <input type="reset" id="reset_form" name="submit" value="Reset" class="button" />

I'm also using facebox to open up the reporting.php file. 我也使用facebox打开reporting.php文件。

This is my SQL table http://screensnapr.com/v/2pZMN7.png 这是我的SQL表http://screensnapr.com/v/2pZMN7.png

I seriously do not know what it is that I'm doing wrong. 我真的不知道我做错了什么。 Could anyone help me? 谁能帮助我?

You are trying to insert 6 values into a 5 column table 您正尝试将6个值插入到5列表中

INSERT INTO reportcomment (id, name, commentid, date, ip) VALUES
                            1     2          3     4   5
  (NULL,'{$_GET['id']}','{$form_name}','{$form_commentid}','{$date}','{$ip}')") 
      1               2              3                   4         5       6

Remove the NULL value 删除NULL

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

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