When I add the mysqli_connect statement in my php file it stops working the whole script. If make this statement comment my php file works as expected. I am adding this file to a wordpress website.
I have tried to connect using mysql_connect() also but the result is same.
My Code:
<?php
require_once ($_SERVER['DOCUMENT_ROOT'].'/wp-config.php');
ini_set('display_errors', 1);
error_reporting(E_ALL);
//phpinfo();
echo DB_NAME ."<br>";
echo DB_USER ."<br>";
echo DB_PASSWORD ."<br>";
echo DB_HOST."<br>"
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);
// database port is also 3306 which is default
if (!$conn) {
echo "Connection failed: " . mysqli_connect_error();
}
echo "Connected successfully";
?>
php.info() outputs that mysqli is installed is also enabled.
Do I need to include some file to access mysqli_connect() function.
How can I connect to the database?
echostatements are fine and shows the proper output if I remove themysqli_connect()and oter db related statements but in combinations I get nothing in output