PHP Executing Differently at the Client Side
Posted: Tue Feb 17, 2004 7:37 pm
Hello Folks
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.
The wierd thing is for 98 out of 100 users this processes fine. But, for 2 of those users when you go echo substr($insertStatement, 0, -2); it returns...
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
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