|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-02 11:09 UTC] tony2001@php.net
[2005-07-10 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
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.