![]() |
![]() |
icy_negi84 |
![]()
Post
#1
|
Group: Members Posts: 8 Joined: 21-May 14 Member No.: 20,958 ![]() |
I'm new in PHP getting error while inserting data
error: Unable to add data 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 ''')' at line 1 my code: <?php if(isset($_POST['add'])) { $dbhost='localhost'; $dbuser='root'; $dbpass='ricky'; $conn=mysql_connect($dbhost,$dbuser,$dbpass); if(!$conn) { die('unable to connect to database' .mysql_error()); } /* if(! get_magic_quotes_gpc()) { $Name=addslashes($_POST['Name']); $Email=addcslashes($_POST['Email']); $Contact=addcslashes($_POST['Contact']); $messgae=addcslashes($_POST['message']) } else { $Name=$_POST['Name']; $Email=$_POST['Email']; $Contact=$_POST['Contact']; $messgae=$_POST['message']; }*/ $sql="INSERT INTO contact1". "(Name,Email,Contact,message)". "VALUES('$Name','$Email',$Contact,'$message')"; mysql_select_db('hotel'); $retval=mysql_query($sql,$conn); if(! $retval) { die('Unable to add data' .mysql_error()); } echo "Thank you for contacing us ![]() mysql_close($conn); } ?> or I tried this also: <?php if(isset($_POST['add'])) { $dbhost='localhost'; $dbuser='root'; $dbpass='ricky'; $conn=mysql_connect($dbhost,$dbuser,$dbpass); if(!$conn) { die('unable to connect to database' .mysql_error()); } /* if(! get_magic_quotes_gpc()) { $Name=addslashes($_POST['Name']); $Email=addcslashes($_POST['Email']); $Contact=addcslashes($_POST['Contact']); $messgae=addcslashes($_POST['message']) } else { $Name=$_POST['Name']; $Email=$_POST['Email']; $Contact=$_POST['Contact']; $messgae=$_POST['message']; }*/ $sql="INSERT INTO contact1". "(Name,Email,Contact,message)". "VALUES('$Name','$Email',$Contact,'$message')"; mysql_select_db('hotel'); $retval=mysql_query($sql,$conn); if(! $retval) { die('Unable to add data' .mysql_error()); } echo "Thank you for contacing us ![]() mysql_close($conn); } ?> |
![]() ![]() |
icy_negi84 |
![]()
Post
#2
|
Group: Members Posts: 8 Joined: 21-May 14 Member No.: 20,958 ![]() |
Is there any one I need help
![]() ![]() ![]() ![]() ![]() ![]() This post has been edited by icy_negi84: May 21 2014, 02:08 PM |
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 13th June 2024 - 03:00 PM |