#18819 [NEW]: mysqp_select_db() can't be called from within user defined functions
| From: | php at arc2 dot co dot uk | Date: | Fri, 09 Aug 2002 00:07:12 +0000 |
| Subject: | #18819 [NEW]: mysqp_select_db() can't be called from within user defined functions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-16337@lists.php.net to get a copy of this message | ||
From: php@arc2.co.uk
Operating system: Linux
PHP version: 4.2.1
PHP Bug Type: MySQL related
Bug description: mysqp_select_db() can't be called from within user defined functions
I've tested this extensively on PHP v4.2.1 and Apache v1.3.26...
can't get the function, mysql_select_db(), to work from within a user
defined
function...
e.g. file "functions.php"...
include("config.php"); // database name etc.
$db = ("mydb");
mysql_connect($hostname, $user, $pass) OR DIE("Unable to connect to
database");
/* if you included the following code WITHIN the function, it won't work.
It works as long as it's placed before the start of the function: */
mysql_select_db($db);
/* and here's the function */
function adminstuff() {
// $result = mysql_query('SELECT uid, uname FROM users');
// $resultrow = mysql_fetch_array($result);
// return array ($resultrow[0], $resultrow[1]);
/* Select all users with the preference Apples */
$query = "SELECT * FROM users";
$result = MYSQL_QUERY($query);
/* How many of these users are there? */
$number = MYSQL_NUMROWS($result);
END---
The error returned is:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result
resource in /functions.php on line 40
If one adds an OR DIE command to the end of the mysql_select_db()
function, this is where the script halts.
Noel da Costa
www.arc2.co.uk
This code was running on ipowerweb.com web hosting servers, so I don't
have access to gbd and all the technical gumf.
Apache Server Software: Apache/1.3.26 (Unix) mod_bwlimited/1.0 PHP/4.2.1
mod_log_bytes/0.3 FrontPage/5.0.2.2510 mod_ssl/2.8.9 OpenSSL/0.9.6b
--
Edit bug report at http://bugs.php.net/?id=18819&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18819&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18819&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18819&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18819&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18819&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18819&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18819&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18819&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18819&r=globals