MANO MANO MANO MANO - 2 years ago 120
MySQL Question

Not able to connect to mysql from php using netbeans project

I am trying to learn php on my own. Things were OK till i reach DB connection.

I am using NetBeans 8.1 and had installed xampp to set up mysql and apache server. But when i try to connect to DB using

$dbPassword = "PHPpassword";
$dbUserName = "PHPuser";
$dbServer = "localhost";
$dbName = "PHPFirstDB";

$connection = new mysqli($dbServer, $dbUserName, $dbPassword, $dbName);

Ideally i should be seeing $connection details but I am not able to see anything in the script output window. I have set runas : script(run in command line)

Can anyone help me here...

Answer Source

Try this code, it could be possible that the error is occurring but not being displayed.

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());

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download