I've tried several different connection solutions throughout the day, but I keep experiencing internal server error 500 in one way or the other.
I have made a seperate connection.php document which is the code shown below:
$user = 'root';
$password = 'root';
$db = 'Vilduhelst';
$host = 'localhost';
$mysqli = new mysqli($host, $user, $password, $db);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
However, if I try to add the following code to the document, I get an error 500:
function performQuery($sql){
global $mysqli;
$result = mysqli_query($mysqli, $sql);
if ($result){
return $result;
} else {
echo 'Something went wrong'
return null;
}
}
Does anybody know why?