Jump to content

[SOLVED] PHP/Mysql_query problem


gevensen

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'";

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.