![]() |
![]() |
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); } ?> |
![]() ![]() |
jimlongo |
![]()
Post
#2
|
This is My Life ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 ![]() |
now you're mixing mysql and mysqli functions, I don't think you can do that.
no the query is = INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...) This post has been edited by jimlongo: May 21 2014, 02:56 PM |
![]() ![]() |
![]() |
Lo-Fi Version | Time is now: 13th June 2024 - 09:08 PM |