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
https://forums.phpfreaks.com/topic/162777-solved-phpmysql_query-problem/
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.

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

 

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

Archived

This topic is now archived and is closed to further replies.

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