0

Resolved Thank you everyone! It turned out "Group" was a registered mysql term so I changed "Group" to Web_Group. Phew... This was frustrating me all night. Thank you so much stackoverflow users!

I keep trying to write to a column in mysql which is "Group" and it doesn't work.

$query = mysql_query("INSERT INTO users SET username='$username',password='$pass',mcname='$mcname',Group='Member',email='$email',confirm='$confirmcode',status='0'");

The weird part is if I take out Group='Member' The code works flawlessly. Yes the column "group" starts with a capital letter so that isn't the problem.

What can I do to fix this?

The MySQL error is:

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 'Group='Member',email='sdfsdf',confirm='1d4ba9f5cbb214965b4f6ba5ad1c4fba',status=' at line 1

3 Answers 3

2

At first glance, I think the error is that your column name is group which is a reserved word. http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

You could escape the column name with backticks: ` like this:

`Group`="Value"
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! I ended up just changing "Group" to "Web_Group"
No worries - I always consult that table before creating DBs. It's funny that Type or Number are not reserved but Group is. This used to catch me out a lot :)
1

The word "Group" is a MySQL reserved word so you need to add back-ticks (`) around the column name.

Try doing the following:

$query = mysql_query("INSERT INTO users SET username='$username',password='$pass',mcname='$mcname',`Group`='Member',email='$email',confirm='$confirmcode',status='0'");

Comments

0

Here is the correct systax if you wanna insert to your database table

$query = mysql_query("INSERT INTO users (username,password,mcname,Group,email,confirm,status) VALUES('$username','$pass','$mcname','Member','$email','$confirmcode','0')");

1 Comment

Thanks for the INFO i never thought that mysql is not so case sensitive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.