Jump to content

Custom Function Help


master82

Recommended Posts

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]<?php

include("connect.php");

function usercount() {
$users = mysql_query("SELECT * FROM users", $connect);
$num_rows = mysql_num_rows($users);

print "$num_rows";

}

//test function
usercount();

?>[/code]

Output:
[code]
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in blabla\functions.php on line 6

Warning: 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.