MySQL Syntax error. Can't solve it

前端 未结 5 2063
南方客
南方客 2021-01-26 01:22

I wanna insert 0 to some db table\'s fields but can\'t get it work. The piece of code from my signup php script looks like that.

...

if (isset($type))
{         


        
5条回答
  •  执笔经年
    2021-01-26 01:42

    Given your edit, you've mis-quoted the word group. YOu can't use single quotes to turn a reserved word into an "acceptable" word, it has to be backticks:

    INSERT ....., `group`, ... VALUES ....
                  ^-----^--- note the backticks
    

    Single quotes turn anything into a string, but you can't use a string for a field name.

    In the future, if you'r getting an SQL syntax error, show us the actual query that's causing the error. Generally the PHP that's building the query is not necessary - we want to see what MySQL is complaining about. Only after we figure out what the actual problem is can we tell you how to change your code to fix the problem.

提交回复
热议问题