master82 Posted November 27, 2006 Share Posted November 27, 2006 Im trying to create a simple custom function that will count the number of rows in my users table, but this is my 1st time creating custom functions and i havent quiet got the hang of it...[code]<?phpinclude("connect.php");function usercount() {$users = mysql_query("SELECT * FROM users", $connect);$num_rows = mysql_num_rows($users);print "$num_rows";}//test functionusercount();?>[/code]Output:[code]Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in blabla\functions.php on line 6Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in blabla\functions.php on line 7[/code]Can anyone please help? Link to comment https://forums.phpfreaks.com/topic/28591-custom-function-help/ Share on other sites More sharing options...
Hypnos Posted November 27, 2006 Share Posted November 27, 2006 [code]<?phpinclude("connect.php");function usercount() {$connect = $GLOBALS['connect'];$users = mysql_query("SELECT * FROM users", $connect);$num_rows = mysql_num_rows($users);print "$num_rows";}//test functionusercount();[/code] Link to comment https://forums.phpfreaks.com/topic/28591-custom-function-help/#findComment-130824 Share on other sites More sharing options...
master82 Posted November 27, 2006 Author Share Posted November 27, 2006 your a star! Link to comment https://forums.phpfreaks.com/topic/28591-custom-function-help/#findComment-130826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.