|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-04 18:07 UTC] michaelmunsie at yahoo dot com
-Status: Open
+Status: Closed
[2010-11-04 18:07 UTC] michaelmunsie at yahoo dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 13:00:01 2025 UTC |
Description: ------------ Using mysql_query and typing "exit" after the call is resulting in duplicate queries. If you take "exit" off the end of the code, the query will be executed only once as it should. $host = "localhost"; $user = "root"; $password = "password"; $databasename = "databasename"; $connection=mysql_connect ($host, $user, $password) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($databasename); $sql = "INSERT INTO table(field, field2, field3) VALUES('value1', 'value2', 'value3')"; $result = mysql_query($sql,$connection) or die ('Database error: ' . mysql_error()); exit; // take this off and the call is executed once Test script: --------------- $host = "localhost"; $user = "root"; $password = "password"; $databasename = "databasename"; $connection=mysql_connect ($host, $user, $password) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($databasename); $sql = "INSERT INTO table(field, field2, field3) VALUES('value1', 'value2', 'value3')"; $result = mysql_query($sql,$connection) or die ('Database error: ' . mysql_error()); exit; // take this off and the call is executed once