#38475 [Opn->Fbk]: mysql_error doesn't reset after mysql_* func call

From: Date: Wed, 16 Aug 2006 23:20:44 +0000
Subject: #38475 [Opn->Fbk]: mysql_error doesn't reset after mysql_* func call
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100879@lists.php.net to get a copy of this message
ID: 38475 Updated by: tony2001@php.net Reported By: mirya at matrix dot ua -Status: Open +Status: Feedback Bug Type: MySQL related Operating System: FreeBSD6.1 PHP Version: 5.1.4 New Comment: Can't replicate. Please provide reproduce code that really works. Previous Comments: ------------------------------------------------------------------------ [2006-08-16 18:03:49] mirya at matrix dot ua Description: ------------ Extract from mysql_error() php doc page: "Note that this function only returns the error text from the most recently executed MySQL function (not including mysql_error() and mysql_errno())..." I noticed that a error is not reset for mysql_fetch_*() call (server/client 5.0.22), mean if you perform mysql_query() for some data manipulation statement producing a error, then call mysql_fetch_*(), mysql_error() will return mysql_query() error message. So the docs page is inconsistent with current mysql lib behaviour Reproduce code: --------------- mysql_connect('localhost', 'mirya', 'my-passwd'); mysql_select_db('test'); mysql_query('CREATE TABLE a (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB'); mysql_query('CREATE TABLE b (b INT AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, FOREIGN KEY (a) REFERENCES a(a) ON DELETE REST mysql_query('INSERT a VALUES (1), (2), (3)'); $rs = mysql_query('SELECT a FROM a'); while ($row = mysql_fetch_assoc($rs)) { if (mysql_error()) die('Shouldn\'t happen: '.mysql_error()); mysql_query('INSERT b (a) VALUES (4)'); if (mysql_error()) echo "Foreign key constraint fails\n"; } echo "Finished w/o errors\n"; Expected result: ---------------- Foreign key constraint fails Finished w/o errors Actual result: -------------- Foreign key constraint fails Shouldn't happen: Cannot add or update a child row: a foreign key constraint fails (test/b, CONSTRAINT b_ibfk_1 FOREIGN KEY (a) REFERENCES a (a)) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38475&edit=1

« previous php.bugs (#100879) next »