php + mysql插入错误
我正在创建一个简单的表单注释,将允许用户使用php mysql jquery发送注释和inserti进入数据库,在页面中没有刷新所有工作正常但问题是:当我写我评论mysql数据库需要4行并填写相同的数据,任何人都可以帮我解决错误?
my_db.sql
-- -- Database: `my_db` -- -- -------------------------------------------------------- -- -- Table structure for table `comments` -- CREATE TABLE IF NOT EXISTS `comments` ( `id` tinyint(4) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `email` varchar(70) NOT NULL, `comments` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Dumping data for table `comments` -- INSERT INTO `comments` (`id`, `name`, `email`, `comments`) VALUES (1, 'test', 'test@test.com', 'testcomments'), (2, 'test', 'test@test.com', 'testcomments'), (3, 'test', 'test@test.com', 'testcomments'), (4, 'test', 'test@test.com', 'testcomments'); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
index.php // jquery的forms和function
feedback page $(function(){ $('#submit').click(function(){ $('#container').append(''); var name = $('#name').val(); var email = $('#email').val(); var comments = $('#comments').val(); $.ajax({ url: 'submit_to_db.php', type: 'POST', data: 'name =' + name + '&email=' + email + '&comments=' + comments, success: function(result){ $('#response').remove(); $('#container').append('' + result + '
'); $('#loading').fadeOut(500, function(){ $(this).remove(); }); } }); return false; }); });