Why sometimes Insert Does not work?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rashed
Forum Newbie
Posts: 17
Joined: Fri Jun 06, 2003 6:27 am
Location: Islamabad, Pakistan.

Why sometimes Insert Does not work?

Post 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?
corlando
Forum Newbie
Posts: 21
Joined: Sun Jun 15, 2003 10:07 pm

Post 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')");

?>
Post Reply