php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3065 Solution to '...undefined function mysql_errno()'
Submitted: 1999-12-29 11:01 UTC Modified: 1999-12-29 11:26 UTC
From: pcg at gospelcom dot net Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.12 OS: Linux (RH6.0, kernel 2.2.13)
Private report: No CVE-ID: None
 [1999-12-29 11:01 UTC] pcg at gospelcom dot net
As with bug #2329, I'm getting 'Fatal error: Call to unsupported or undefined function mysql_errno()...' from a script.

The problem is that with MySQL-3.23 mysql_errno is NOT #define'd, as it was with 3.22--it is a true function. Thus, in lines 118-120 of functions/mysql.c, where mysql_errno is tested to be defined or not, php3_mysql_errno doesn't get declared.

The following patch tests if mysql_errno is defined OR if the MySQL version is 3.23. If either is true, it defines a variable (HAVE_MYSQL_ERRNO). The rest of functions/mysql.c tests if this variable is defined, rather than testing if mysql_errno is defined.

Though this patch is untested, it compiled fine and the proper symbols resulted in libmodphp3.a. Compilation was done with egcs 2.91.66, apache_1.3.9, php-3.0.12, and both mysql-3.22.25 and 3.23.7. (Undoubtedly there will be problems with linewrapping; please e-mail me if you want the raw text.)

--- cut here ---
diff -ru php-3.0.12-orig/functions/mysql.c php-3.0.12/functions/mysql.c
--- php-3.0.12-orig/functions/mysql.c   Sun Jul  4 13:30:42 1999
+++ php-3.0.12/functions/mysql.c        Wed Dec 29 10:57:15 1999
@@ -98,6 +98,10 @@
 #define mysql_row_length_type unsigned int
 #endif

+#if defined(mysql_errno) || MYSQL_VERSION_ID > 32299
+#define HAVE_MYSQL_ERRNO 1
+#endif
+
 #define MYSQL_ASSOC            1<<0
 #define MYSQL_NUM              1<<1
 #define MYSQL_BOTH             (MYSQL_ASSOC|MYSQL_NUM)
@@ -115,7 +119,7 @@
        {"mysql_list_tables",   php3_mysql_list_tables,         NULL},
        {"mysql_list_fields",   php3_mysql_list_fields,         NULL},
        {"mysql_error",                 php3_mysql_error,
NULL},
-#ifdef mysql_errno
+#ifdef HAVE_MYSQL_ERRNO
        {"mysql_errno",                 php3_mysql_errno,
NULL},
 #endif
        {"mysql_affected_rows", php3_mysql_affected_rows,       NULL},
@@ -529,7 +533,7 @@
 #if APACHE
                        handler=signal(SIGPIPE,SIG_IGN);
 #endif
-#if defined(mysql_errno) && defined(CR_SERVER_GONE_ERROR)
+#if defined(HAVE_MYSQL_ERRNO) && defined(CR_SERVER_GONE_ERROR)
                        mysql_stat(le->ptr);
                        if (mysql_errno((MYSQL *)le->ptr) == CR_SERVER_GONE_ERROR) {
 #else
@@ -1144,7 +1148,7 @@

 /* {{{ proto int mysql_errno([int link_identifier])
    Returns the number of the error message from previous MySQL operation */
-#ifdef mysql_errno
+#ifdef HAVE_MYSQL_ERRNO
 void php3_mysql_errno(INTERNAL_FUNCTION_PARAMETERS)
 {
        pval *mysql_link;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-12-29 11:26 UTC] rasmus at cvs dot php dot net
Fixed in CVS - will be in 3.0.13
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 10:01:32 2024 UTC