Error in query while performing insert
this is my code and for which i m getting开发者_如何转开发 error query mssg:
$name = mysqli_real_escape_string($dbc, trim($_POST['fname']));
$emailid = mysqli_real_escape_string($dbc, trim($_POST['emailid']));
$city = mysqli_real_escape_string($dbc, trim($_POST['city']));
$comment = mysqli_real_escape_string($dbc, trim($_POST['comment']));
$query="INSERT INTO userdate('name','city','emailid','pledge','date') VALUES ('$name','$city','$emailid','$comment',NOW())";
$result=mysqli_query($dbc, $query) or die('error query');
You have single quotes and not backticks in your query.
$query="INSERT INTO userdate('name','city','emailid','pledge','date') VALUES ('$name','$city','$emailid','$comment',NOW())";
Should be:
$query="INSERT INTO userdate(`name`,`city`,`emailid`,`pledge`,`date`) VALUES ('$name','$city','$emailid','$comment',NOW())";
精彩评论