|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-08-08 20:52 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 15:00:01 2025 UTC |
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