note 46102 added to function.mysql-insert-id

From: Date: Wed, 29 Sep 2004 13:59:38 +0000
Subject: note 46102 added to function.mysql-insert-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-77566@lists.php.net to get a copy of this message
Never, EVER forget that Apache 2 is multithreaded. So, writing mysql_query($query); $id = mysql_insert_id(); Will eventually cause a disaster (data corruption and the like, depending on your code) as soon as two threads do a query at the same time. Additionally, these sort of bugs are almost impossible to track down. The correct code is: $resource = mysql_query($query); $id = mysql_insert_id($resource); ---- Manual Page -- http://www.php.net/manual/en/function.mysql-insert-id.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46102 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46102&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46102&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77566) next »