gevensen Posted June 18, 2009 Share Posted June 18, 2009 I am having a problem with my syntax in a mysql_query command I get the error message 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 '`departmental_reviews` = `1`, `department` = `General`, `added_by` = `geve' at line 13 The syntax im using is: $sql_insert="UPDATE `masterlogin`.`sc_users` SET `name` = `$saved_name`, `username` = `$user_name`, `password` = `$encrypted_password`, `db`=`$db`, `email` = `$saved_email`, `dateregistered` = `$today`, `picname`=`$picname`, `super_admin`= `$super_admin`, `full_admin` = `$full_admin`, `data_entry` = `$data_entry`, `report_access` = `$report_access`, `audit` = `$audit` `departmental_reviews` = `$departmental`, `department` = `$department`, `added_by` = `$added_by`, `admin_db` = `$admin_db`, WHERE `sc_users`.`id` = $pulled_id LIMIT 1 "; Any idea what im doing wrong? I notice that the phpmyadmin uses ` instead of ' but i have tried it both ways it was working until i added a couple of fields, they are all in the database though and spelled properly Quote Link to comment Share on other sites More sharing options...
Maq Posted June 18, 2009 Share Posted June 18, 2009 Missing a comma after $audit. Please use tags around code. Quote Link to comment Share on other sites More sharing options...
gevensen Posted June 18, 2009 Author Share Posted June 18, 2009 DOYYYY..... I cant beleive i missed that But im still getting an error after fixing that 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 'WHERE `sc_users`.`id` = `70` LIMIT 1' at line 17 Missing a comma after $audit. Please use tags around code. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted June 18, 2009 Share Posted June 18, 2009 You have a comma that doesn't belong here `admin_db` = `$admin_db`, Quote Link to comment Share on other sites More sharing options...
Maq Posted June 18, 2009 Share Posted June 18, 2009 That comma must have fell down off of audit. Quote Link to comment Share on other sites More sharing options...
gevensen Posted June 18, 2009 Author Share Posted June 18, 2009 yes i just noticed that also and was coming back to note that but now i am getting another error it says Unknown column 'BILL SMITH' in 'field list' Bill Smith is the user I am adding which is the variable $saved_name $sql_insert2="UPDATE `masterlogin`.`sc_users` SET `name` = `$saved_name`, `username` = `$user_name`, `password` = `$encrypted_password`, `db`=`$db`, `email` = `$saved_email`, `dateregistered` = `$today`, `picture_name` = `$picname`, `super_admin` = `$super_admin`, `full_admin` = `$full_admin`, `data_entry` = `$data_entry`, `report_access` = `$report_access`, `audit` = `$audit`, `departmental_reviews` = `$departmental`, `department` = `$department`, `added_by` = `$added_by`, `admin_db` = `$admin_db` WHERE `sc_users`.`id` = '$pulled_id'"; Quote Link to comment Share on other sites More sharing options...
gevensen Posted June 18, 2009 Author Share Posted June 18, 2009 OK thanks all It had to do with the symbol ` instead of ' Its working now Quote Link to comment Share on other sites More sharing options...
Maq Posted June 18, 2009 Share Posted June 18, 2009 OK thanks all It had to do with the symbol ` instead of ' Its working now I don't even know where the error even was... You should only be using back ticks ` around table and field names, and single quotes ' around values (except INTs). Quote Link to comment 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.