Anomaly , mysql insert doesnt work

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Sep 27, 2012 10:55 am

Wed Oct 03, 2012 10:50 am

Instead of the literal and double quotes, try it with just the literals.

Code: Select all

$Inkelti = mysql_query("INSERT INTO `Ieskomi`(ID, VardasPavarde, GimimoMetai, Salys, Miestas, Lytis, Dingo, Apibudinimas, Nuotrauka, Statusas, KadaInkele, Inkele)
         VALUES(NULL, '$VardasPavarde', '$GimimoMetai', '$Salys', '$Miestas', '$Lytis' '$Dingo', '$Apibudinimas', '$Nuotrauka', '$Statusas', '$DATA', '$Inkele')");
Also if the column tab order is the same as your value list, you can shorten the INSERT statement to:

Code: Select all

$Inkelti = mysql_query("INSERT INTO `Ieskomi` VALUES('', '$VardasPavarde', '$GimimoMetai', '$Salys', '$Miestas', '$Lytis' '$Dingo', '$Apibudinimas', '$Nuotrauka', '$Statusas', '$DATA', '$Inkele')");
Note that the first value (ID) is empty. This assumes you are auto_incrementing the column. Finally, you should consider using prepared statements instead mysql_* functions.

Good luck

Post Reply