I have a problem in my remote server when I used php to connect MySQL using Netbeans
This is my PHP Code:
<?php
$dbPassword = "********";
$dbUserName = "********";
$dbServer = "192.168.1.98"; //Remote Server with LAMP
$dbName = "test";
ini_set('display_errors',1);
error_reporting(E_ALL ^ E_NOTICE);
$connection = new mysqli($dbServer,$dbUserName,$dbPassword,$dbName);
if (mysqli_connect_error()) {
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}
print_r($connection);
?>
I used the given code based on this user's reply to check for error, else it wont show anything.
This is the result:
mysqli Object ( [affected_rows] => 0 [client_info] => mysqlnd 5.0.12-dev
- 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
[client_version] => 50012 [connect_errno] => 0 [connect_error] => [errno] => 0
[error] => [error_list] => Array ( ) [field_count] => 0 [host_info] =>
192.168.1.98 via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.7.19-
0ubuntu0.16.04.1 [server_version] => 50719 [stat] => Uptime: 4794 Threads: 5
Questions: 1574 Slow queries: 0 Opens: 339 Flush tables: 1 Open tables: 166
Queries per second avg: 0.328 [sqlstate] => 00000 [protocol_version] => 10
[thread_id] => 182 [warning_count] => 0 )
*Seriously??
My php is working when I test with phpinfo()
, but seems like unable to connect mysql database
The part that confuse me is when I leave the password blank for mysql in phpcode: It show this:
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'joeslie'@'192.168.1.98' (using password: YES) in /var/www/html/files/config.php on line 11 Connect Error (1045) Access denied for user 'joeslie'@'192.168.1.98' (using password: YES)
So I can say that the PHP still possible to communicate and identify wrong password. Any suggestion?