php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41543 Mysql_result doesnt report error code
Submitted: 2007-05-30 15:54 UTC Modified: 2007-05-30 16:06 UTC
From: benjicharlton at gmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.2 OS: WAMP (winxp)
Private report: No CVE-ID: None
 [2007-05-30 15:54 UTC] benjicharlton at gmail dot com
Description:
------------
in this example the table called has no entries.  Therefore mysql_result ($title,0) should produce an error....which it does however it appears ERROR_NO = 0 and no message is associated. 

Obviously my work around was to create my own error trap but my normal "OR DIE" is "or DIE(mysql_errno)

which doesn't really help anyone debug code failure.

Reproduce code:
---------------
mysql_select_db($database_db_connect, $db_connect);
$query_title ="SELECT MAX(TitleID) FROM title";
$title = mysql_query($query_title, $db_connect) or die(mysql_error());
$id_title = mysql_result($title,0);
if (!$id_title){echo "error:";die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $title . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());}

Expected result:
----------------
A fatal MySQL error occured.
Query: Resource id #6
Error(#num) Result set contained no rows.

Actual result:
--------------
A fatal MySQL error occured.
Query: Resource id #6
Error(0)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-30 15:56 UTC] benjicharlton at gmail dot com
err I mean "or Die(mysql_errno()) when refering to my normal or Die commands.
 [2007-05-30 16:06 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 12:00:02 2025 UTC