Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is my MySQL query failing

I can't get this to work, keep getting an error message.

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 '-mail, password, 
birth_date, age, sex, profile_text, zip_code, zip_code_state, c' at line 1

Code

mysql_query("INSERT INTO users (username, e-mail, password, birth_date, age, sex,
      profile_text, zip_code, zip_code_state, coins, rank, profile_visits, 
      profile_likes, profile_image, profile_points, activated, deleted, reg_time, 
      last_active_time, reg_ip)
    VALUES ('$randomName', '[email protected]', 'awd', '21/05/1990','0','2',
      '0','4306','Sandnes','0','user','0','0','$image','0','0','0','$time',
      '$time','0')")
 or die(mysql_error());
like image 842
Ninja__1881 Avatar asked Dec 16 '22 03:12

Ninja__1881


1 Answers

Surround e-mail with backticks...

`e-mail`,

You can't drop a - there otherwise.

like image 121
alex Avatar answered Jan 02 '23 22:01

alex