简体   繁体   中英

Simple registration form will not inset into db

I am trying to make a simple registration form (which does not need to be too secure, as its just to see who is participating.) However, whatever I try to do, I keep getting this 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 'from, email, phone, accommodation, nights, room, talk, comments, pass) VALUES ' at line 1

Code:

    mysql_query("INSERT INTO participants (name, from, email, phone, accommodation, nights, room, talk, comments, pass) VALUES 
                ('$name', '$from', '$email', '$phone', '$accommodation', '$nights', '$room', '$talk', '$comments', '$pass')") or die(mysql_error()); 

Any ideas?

FROMSQL中保留字 ,需要将其放在引号中。

(`name`, `from`, ...

try this

mysql_query("INSERT INTO participants (name, from, email, phone, accommodation, nights, room, talk, comments, pass) VALUES 
           ($name, $from, $email, $phone, $accommodation, $nights, $room, $talk, $comments, $pass)") or die(mysql_error()); 

but..

FROM it is reserve word..

Reserved Words

MySql Doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM