Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

weird error using 'where' in sql

Explorer ,
Mar 22, 2012 Mar 22, 2012

I have this code to retrieve user records:

$sql = "Select * from members

        WHERE group = '$group'";

        $sql_result = mysql_query($sql,$connection1)

            or exit("Sql Error: " . mysql_error());

        $sql_num = mysql_num_rows($sql_result);

i get the error:

Sql 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 'group = 1' at line 2

not sure what's wrong with that...

TOPICS
Server side applications
420
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 22, 2012 Mar 22, 2012

"group" is a reserved word in SQL. I'm suprised MySQL allows you to create a column with that name. You might be able to enclose it in quotes, but you really should change that column name.

Translate
LEGEND ,
Mar 22, 2012 Mar 22, 2012
LATEST

"group" is a reserved word in SQL. I'm suprised MySQL allows you to create a column with that name. You might be able to enclose it in quotes, but you really should change that column name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines