I am breaking my head why I cannot make a succesful database connection. When I am using the below code I get a blank page with this error: 500: There is an error while processing this request
. The dbname, username, code is 100% correct. If i just set in:<?php echo "Hello World";?>
the page is working fine and echo out Hello World. So I guess it has to be something to do with my database connection code?
Can anybody see what I am doing wrong here?
index.php:
<?php
include 'db_connection.php';
$conn = OpenCon();
echo "Connected Successfully";
CloseCon($conn);
?>
db_connection.php:
<?php
function OpenCon()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "mycode";
$db = "store";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
return $conn;
}
function CloseCon($conn)
{
$conn -> close();
}
?>
Image of the MySQL files:
I am running the database in a Synology DS918 server. As I recall the log is under /var/log/mysql/
. But I cannot find that path here. Does anybody knows where the log should lay?