i am trying to insert data to mysql table using php i tried so many times but i can't figure out what's problem here. i tried to display query using echo. it's displaying this.
INSERT INTO `inquiry` (id,name,contact,email,query) values ('',vijay,15461485,asasf@gmail.com, ewefasd asdsd)
and my php query is this.
<?php
include('config.php');
if (isset($_POST['submit'])) {
$name=$_POST['userName'];
$mail=$_POST['userMail'];
$phone=$_POST['userPhone'];
$msg=$_POST['userMsg'];
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
test_input($name);
test_input($mail);
$query="INSERT INTO `inquiry` (id,name,contact,email,query) values ('',$name,$phone,$mail,$msg)";
$qur=mysql_query($query);
if ($qur) {
header('location:'. $_SERVER['HTTP_REFERER']);
}
else {
echo $query;
}
}
?>
when i try that display query to mysql it's displaying like this.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com, ewefasd asdsd)' at line 1
what's problem here,i don't know,please help me.