Jump to content

MYSQL Insert Error


smartguyin

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/226146-mysql-insert-error/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/226146-mysql-insert-error/#findComment-1167427
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.