php - mySQL error, that I can't find -


i'm writing because can't find error, copied code document , edited few things, have error. i'm unable see is.

the following error is:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'by,telefon,email) values (987, , , , by, , )' @ line 1

and code following:

 $taelf = mysql_result(mysql_query("select count(*) `firma` `navn` = '$navn'"),0);   if($taelf < 1){        mysql_query("insert `firma` (navn,cvr,adresse,postnr,by,telefon,email)                    values ($_post[navn], $_post[cvr],                            $_post[adresse], $_post[postnr],                            by, $_post[nummer], $_post[email]                           )"                 ) or die(mysql_error());       echo "<div id='success'>vupti, firmaet er nu oprettet. '$_post[navn]','$_post[cvr]','$_post[adresse]','$_post[by]','$_post[postnr]','$_post[nummer]','$_post[email]'</div>"; 

by reserved word. if going name column name must wrap in ticks:

insert `firma` (navn,cvr,adresse,postnr,`by`,telefon,email)  

also see fabien warniez's answer explains need wrap string values in quotes.

please, don't use mysql_* functions in new code. no longer maintained and officially deprecated. see red box? learn prepared statements instead, , use pdo or mysqli - this article decide which. if choose pdo, here tutorial. you wide open sql injections


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -