sql query isnt working

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bluestar
Forum Newbie
Posts: 13
Joined: Thu Mar 17, 2011 7:19 am

sql query isnt working

Post by bluestar »

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;
}
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: sql query isnt working

Post by califdon »

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.
Post Reply