can any one solve this sql query problem...
Posted: Wed May 04, 2011 4:55 am
i keep on getting error message:
"Database 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 'NAME, LAST NAME, SEX, DOB, COLLEGE, BRANCH, ADMISSION, PASSOUT) VALUES at line 1"
$this->dblink holds the conn info and database selection..part of which is $this->conn_link
similarly realescapestring function performs stripslash..
function insertintodb()
{
$this->dblink();
$table1="member_signup";
$query = 'INSERT INTO '.$table1.'(EMAIL, FIRST NAME, LAST NAME, SEX, DOB, COLLEGE, BRANCH, ADMISSION, PASSOUT) /*problem in this line*/
VALUES("' . $this->realescapestring($_POST['emailid']) . '",
"' . $this->realescapestring($_POST['fname']) . '",
"' . $this->realescapestring($_POST['lname']) . '",
"' . $this->realescapestring($_POST['sex']) . '",
"' . $this->realescapestring($_POST['dob']) . '",
"' . $this->realescapestring($_POST['college']) . '",
"' . $this->realescapestring($_POST['branch']) . '",
"' . $this->realescapestring($_POST['ystart']) .'",
"' . $this->realescapestring($_POST['yend']) . '")';
mysql_query($query,$this->conn_link);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
return TRUE;
}
"Database 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 'NAME, LAST NAME, SEX, DOB, COLLEGE, BRANCH, ADMISSION, PASSOUT) VALUES at line 1"
$this->dblink holds the conn info and database selection..part of which is $this->conn_link
similarly realescapestring function performs stripslash..
function insertintodb()
{
$this->dblink();
$table1="member_signup";
$query = 'INSERT INTO '.$table1.'(EMAIL, FIRST NAME, LAST NAME, SEX, DOB, COLLEGE, BRANCH, ADMISSION, PASSOUT) /*problem in this line*/
VALUES("' . $this->realescapestring($_POST['emailid']) . '",
"' . $this->realescapestring($_POST['fname']) . '",
"' . $this->realescapestring($_POST['lname']) . '",
"' . $this->realescapestring($_POST['sex']) . '",
"' . $this->realescapestring($_POST['dob']) . '",
"' . $this->realescapestring($_POST['college']) . '",
"' . $this->realescapestring($_POST['branch']) . '",
"' . $this->realescapestring($_POST['ystart']) .'",
"' . $this->realescapestring($_POST['yend']) . '")';
mysql_query($query,$this->conn_link);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
return TRUE;
}