Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how do i fix?
Fatal error: Uncaught Error: Call to undefined function mysqli_db_query() in /home/u703005905/domains/hydroblockhub.net/public_html/usersonline/users.php:9 Stack trace: #0 {main} thrown in /home/u703005905/domains/hydroblockhub.net/public_html/usersonline/users.php on line 9


PHP
<?                                                                               

include "config.php";

$t_stamp = time();                                                                                            
$timeout = $t_stamp - $to_secs; 

mysqli_connect($server, $db_user, $db_pass) or die ("Useronline Database CONNECT Error");                                                                   
mysqli_db_query($db, "INSERT INTO CJ_UsersOnline VALUES ('$t_stamp','$REMOTE_ADDR','$PHP_SELF')") or die("Database INSERT Error"); 
mysql_db_query($db, "DELETE FROM CJ_UsersOnline WHERE timestamp<$timeout") or die("Database DELETE Error");
$result = mysql_db_query($db, "SELECT DISTINCT ip FROM CJ_UsersOnline WHERE file='$PHP_SELF'") or die("Database SELECT Error");
$user = mysql_num_rows($result);                                                                  
mysql_close();                                                                                                

if ($user == 1){
	echo "$user User Online";
} 
else{
	echo "$user Users Online";
}


What I have tried:

tried chaning mysql to mysqli and i tried grammer errors but nothing worked(im new sorry)
Posted
Updated 22-Jan-21 16:45pm
Comments
Christian Graus 22-Jan-21 22:29pm    
I would guess you need to include the library you are using?

PHP
mysqli_db_query($db, "INSERT INTO CJ_UsersOnline VALUES ('$t_stamp','$REMOTE_ADDR','$PHP_SELF')") or die("Database INSERT Error"); 

Not necessary a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]
 
Share this answer
 
Comments
BOLEGMA 23-Jan-21 19:38pm    
it was just for me to know how many users are online
How to Connect to MySQL Server through PHP (MySQLi vs. PDO) - Tutorial Republic[^]

The sample seems to make a variable from the call?
 
Share this answer
 
Comments
BOLEGMA 23-Jan-21 19:39pm    
so no errors above?? im asking about line 9

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900