I have a very strange problem, something I have never encountered before. Some PHP code seems to be executing differently on different users machines, something that seems to totally defy server side code.
Here's what is happening. Lets say I have a table called 'names' with two fields and an auto increment on the ID...
ID | name
Then I have an array, which builds up an MySQL insert statement.
Code: Select all
<?php
$array1[0] = 'peter';
$array1[1] = 'paul';
$array1[2] = 'mary';
$insertStatement = 'INSERT INTO names VALUES ';
foreach ($array1 as $var => $val)
{
$insertStatement .= '(null, "'. $val .'"), ';
}
echo substr($insertStatement, 0, -2);
mysql_query(substr($insertStatement, 0, -2), $myDatabaseConnection);
echo mysql_insert_id($myDatabaseConnection);
?>INSERT INTO names VALUE
yet the database insert works. BUT, mysql_insert_id returns 0 even if it was the 100th record to be inserted.
Anyone know whats going on here? This has me completely mystified.
thx in advance