i got error msg :"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 ')' at line 9"
im trying to insert data in mysql...the code is below....
$this->dblink() :i used to set my connection with mysql and choose my database...
similarly realescapestring function perform stripslash and mysql_real_escape_string function
function insertintodb()
{
$this->dblink();
$table1="member_signup";
$query = 'INSERT INTO ' .$table1.
'(EMAIL,FIRSTNAME,LASTNAME,SEX,DOB,COLLEGE,BRANCH,YSTART,YEND)VALUES(
"'.$this->realescapestring($_POST['emailid']). '",
"'.$this->realescapestring($_POST['fname']).'",
"'.$this->realescapestring($_POST['lname']).'",
"'.$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;
}
sql query isnt working
Moderator: General Moderators
Re: sql query isnt working
You have 9 fields listed in the first part of your Insert query, but you only have 8 values. You have skipped the "sex" value, so all the following data would be inserted in the wrong fields if it actually processed. Either add a value for the "sex" field or remove the field from the first part of the query. Also, you have an extra comma at the end of your values, which is what triggered the error. Remove it.