'Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)
my connection:
$con = new mysqli('localhost', 'root', '', 'test');
it does not work with that either:
$con = new mysqli('localhost', 'root', '', 'test', 4306);
Solution 1:[1]
I would request to check if the connection is working first
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
// Check connection
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
?>
See what the error is and then move to the next step based on the error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Abilash Amarasekaran |