smartguyin Posted January 30, 2011 Share Posted January 30, 2011 I have a Form on registration.html through which i trying to get data in mysql through the below php script but there is and mysql syntax error please help me with the below code. <?php $conn = mysql_connect("localhost", "onlinewe_meghraj", "password123") or die(mysql_error()); $db = mysql_select_db("onlinewe_college") or die(mysql_error()); $name1 = $_POST['name1']; $name2 = $_POST['name2']; $year = $_POST['year']; $department = $_POST['deparment']; $group = $_POST['group']; $in_name = $_POST['in_name']; $in_address = $_POST['in_address']; $phone = $_POST['phone']; $email = $_POST['email']; $mobile1 = $_POST['mobile1']; $mobile12 = $_POST['mobile2']; $comment = $_POST['comment']; $result=mysql_query("INSERT INTO register (name1, name2, year, department, group, in_name, in_address, phone, email, mobile1, mobile2, date, comment) VALUES ('$name1', '$name2', '$year', '$department', '$group', '$in_name', '$in_address', '$phone', '$email', '$mobile1', '$mobile2', '".date("Y-m-d h:i:s")."', '$comment')") or die("Insert Error: ".mysql_error()); echo "REGISTRATION DONE"; ?> Please reply. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/226146-mysql-insert-error/ Share on other sites More sharing options...
Pikachu2000 Posted January 30, 2011 Share Posted January 30, 2011 The error is one of the important pieces of the puzzle. What error is being returned? Quote Link to comment https://forums.phpfreaks.com/topic/226146-mysql-insert-error/#findComment-1167425 Share on other sites More sharing options...
smartguyin Posted January 30, 2011 Author Share Posted January 30, 2011 Sorry i forgot to post the error.. Insert Error: 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 'group, in_name, in_address, phone, email, mobile1, mobile2, date, comment) VALUE' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/226146-mysql-insert-error/#findComment-1167427 Share on other sites More sharing options...
jcbones Posted January 30, 2011 Share Posted January 30, 2011 Group is a reserved word in mysql. put it in backticks. `group` Quote Link to comment https://forums.phpfreaks.com/topic/226146-mysql-insert-error/#findComment-1167431 Share on other sites More sharing options...
smartguyin Posted January 30, 2011 Author Share Posted January 30, 2011 Ya Thanks !! Solved... Quote Link to comment https://forums.phpfreaks.com/topic/226146-mysql-insert-error/#findComment-1167438 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.