this is the first time for me to ask a question.
I have a problem with my PHP and the mysqli extension. I use web hosting of Strato (strato.nl / strato.de).
On my pc, I'm using Xampp and use a MySQL server. My PHP file works completely fine locally, but once it gets uploaded, the program crashes at the line $statement->execute()
.
Is there anyone who might have an idea what is going on?
The code:
<?php
$name = htmlspecialchars($_POST['name']);
$mail = htmlspecialchars($_POST['mail']);
$password = htmlspecialchars($_POST['password']);
$password_confirm = htmlspecialchars($_POST['password_confirm']);
$hashPassword = hash('sha256', $password);
$nameCheck = str_replace(' ', '', $name);
$mailCheck = str_replace(' ', '', $mail);
$passwordCheck = str_replace(' ', '', $password);
$hostname = "rdbms.strato.de";
$username = "username";
$password = 'password';
$database = "database";
//Connect to the database
if(!$db = new mysqli($hostname, $username, $password, $database)){
print("Unable to connect to database: " + $db->connect_error);
}
// Check if the chosen username is already in use
if(!$statement = $db->prepare("SELECT hid FROM house WHERE name = ?")){
print("Error on preparing statement (" . $db->connect_errno . "): " . $db->error);
};
$statement->bind_param('s', $name);
$statement->execute();
$result = $statement->get_result();
$row = $result->fetch_assoc();
?>