#33544 [NEW]: mysql_query() duplicate entries

From: Date: Sat, 02 Jul 2005 03:08:10 +0000
Subject: #33544 [NEW]: mysql_query() duplicate entries
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81282@lists.php.net to get a copy of this message
From: mmokhtar at gmail dot com Operating system: FreeBSD PHP version: 4.3.10 PHP Bug Type: dBase related Bug description: mysql_query() duplicate entries Description: ------------ I use mysql_query() to execute an insert statement into MySql db (ver 4.0.21). Sometimes the query executes correctly inserting a unique record into the table. Other times it inserts two duplicate records. I've tested this several times, and get this random result...however more duplicate entries than single entry during my tests. Reproduce code: --------------- $host = 'localhost'; $user = 'user'; $pass = 'pass'; $db = 'db'; //$selected_prj = $_GET['prjID']; $formsubmit = 0; $formsubmit = $_POST['formsubmit']; $conn = mysql_connect($host, $user, $pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($db, $conn) or die("Couldn't access database $db on MySQL server $host: ".mysql_error()); if ($formsubmit == '1'){ $queryInsert = "Insert into prjs (prjOwnerID, prjAssignedTo, prjTypeID, prjName, prjDescription, prjComments, prjStatusID, startDate, endDate, CreateDate, LastUpdate) Values (" . $_POST['ClientID'] . ", " . $_POST['AssignedToID'] . ", " . $_POST['prjTypeID'] . ", '" . $_POST['prjName'] . "', '" . $_POST['prjDescription'] . "', '" . $_POST['prjComments'] . "', " . $_POST['prjStatusID'] . ",'" . $prj_StartDate . "', '" . $prj_EndDate . "', now(), now())"; if(!($Result = mysql_query($queryInsert))){ // get error and error number $errno = mysql_errno($conn); $error = mysql_errno($conn); print("Error $errno: $error<br>\n"); } else{ print("<script language=\"javascript\"> "); print("window.opener.location='./myaccount.php'; "); print("self.close();"); print("</script>"); } } Expected result: ---------------- Record is inserted, opening window gets refreshed and current window is closed. Actual result: -------------- two Records are inserted, opening window gets refreshed and current window is closed. -- Edit bug report at http://bugs.php.net/?id=33544&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33544&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33544&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33544&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33544&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33544&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33544&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33544&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33544&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33544&r=support Expected behavior: http://bugs.php.net/fix.php?id=33544&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33544&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33544&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33544&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33544&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33544&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33544&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33544&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33544&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33544&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33544&r=mysqlcfg

« previous php.bugs (#81282) next »