#18819 [Opn->Bgs]: mysqp_select_db() can't be called from within user defined functions

From: Date: Fri, 09 Aug 2002 00:52:22 +0000
Subject: #18819 [Opn->Bgs]: mysqp_select_db() can't be called from within user defined functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-16339@lists.php.net to get a copy of this message
ID: 18819 Updated by: georg@php.net Reported By: php@arc2.co.uk -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Linux PHP Version: 4.2.1 New Comment: Sorry, but the bug system is not the appropriate forum for asking support questions. 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 Thank you for your interest in PHP. Previous Comments: ------------------------------------------------------------------------ [2002-08-08 20:07:10] php@arc2.co.uk 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 this bug report at http://bugs.php.net/?id=18819&edit=1

« previous php.bugs (#16339) next »