Page 1 of 1

Why sometimes Insert Does not work?

Posted: Tue Jun 17, 2003 6:02 am
by rashed
Sometimes INSERT statement does not work and we do not get any error from MySQL.like
mysql_query(insert into abc(id_gen("abc"),$a,$b,$c))
id_gen("abc") is PK and is auto_inc, $a,$b and $c are strings.

when i print the values using print $qry; the values are correct but no insertion takes place in DB.

Can anyone help me?

Posted: Tue Jun 17, 2003 10:34 am
by corlando
if you are using PK with auto_increment pass NULL as the value. By doing this your are allowing your PK-auto_inc-column to assign a unique value. Otherwise, you might sometimes be trying to insert a duplicate PK value which isn't allowed.

Code: Select all

<?php

mysql_query("INSERT INTO abc VALUES (null, '$a','$b','$c')");

?>