Simple PHP Insert Page has Random Failure with MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I was working on a very simple php page to insert a new record into a mysql 'contacts' table.  For testing, when I would refresh the page it would insert the new record.

This worked fine - MOST of the time. Then, oddly randomly it would stop inserting records. I would click refresh several times and no new records got created. Then I might quit the browser or wait a while etc. then reload and it would work again for a while then stop again...

one clue is the table looked like this with missing serial ID's:

Rec 1 - fields...
Rec 2 - fields...
Rec 3 - fields...
Rec 7 - fields...
Rec 8 - fields...
Rec 12 - fields...
Rec 13 - fields...
Rec 14 - fields...

so it seems the page went to mysql and tried to insert a record but failed for some reason. Since it was static test data - it was all the same so it seems that can be ruled out.

Also this is a very fast server with local mysql - so that should not be an issue.


Any idea why it might be randomly failing to insert records?



---

require_once('inc/db/class.db.php');


/* this for testing */

$_POST['id'] = 1;
$_POST['first'] = 'test';
$_POST['last'] = 'test';
$_POST['cellphone'] = '1112223333';
$_POST['email'] = 'test@xxxxxxxx';
$_POST['city'] = 'test';
$_POST['zip'] = '11111';

$insert = array(

"id"=>$_POST['id'],
"first"=>$_POST['first'],
"last"=>$_POST['last'],
"cellphone"=>$_POST['cellphone'],
"email"=>$_POST['email'],
"city"=>$_POST['city']
"zip"=>$_POST['zip']

);

$db->insert("contacts", $insert);

$newpbid = $db->lastInsertId(); 

echo $newpbid;

-----



--
Thanks,
Dave - DealTek
dealtek@xxxxxxxxx
[db-16]


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux