0

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); 
print_r($connection);

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...

MANO MANO
  • 3
  • 3

1 Answers1

1

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

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);
Jacob Mulquin
  • 3,458
  • 1
  • 19
  • 22
  • there was some progress, no i am getting this error: Fatal error: Class 'mysqli' not found in C:\xampp\htdocs\php\Connection.php – MANO MANO Jul 17 '16 at 14:13
  • What version of xampp, php? http://stackoverflow.com/questions/7250356/how-to-install-mysqli – Jacob Mulquin Jul 17 '16 at 14:22
  • 1
    xampp is latest, 3.2.2, Some of the forums talk about adding the php path to the PATH variable and updating the php.ini files, when i checked i found everything was updated properly. While i was in the Env variable i found there was another variable called "PHPRC", it was updated with the php path of a different folder i changed it to point it from xampp folder. Reopening the netbeans it got working!! thank you – MANO MANO Jul 17 '16 at 14:43