Posted by Martin van den Berg on 10/04/67 11:23
I have this piece of php-code which inserts data into a database.
Before inserting it must verify if the data is unique. The php code
looks something like:
$query = "SELECT id FROM mytable WHERE bla LIKE " . $x .";
$rows = execute( $query )
if ( $rows == 0 )
{
/* some more processing */
$query = "INSERT INTO mytable ...... etc etc
execute( $query )
}
Now here is the problem: when the user enters the page, and directly
refreshes the record is inserted twice.... Is is possible that both
requests are processed simulatiounsly by the server (apache on linux)?
And can I add something like a critical section or semaphore to
overcome this problem.
Thanx,
Martin
Navigation:
[Reply to this message]
|