My problem is that my MYSQLI query a very strange behavior when it comes to prepare a query and then bind params.
define("HOST", "rdbms.strato.de"); // Der Host mit dem du dich verbinden willst.
define("USER", "USER"); // Der Datenbank-Benutzername.
define("PASSWORD", "PASSWORD"); // Das Datenbank-Passwort.
define("DATABASE", "DATABASE"); // Der Datenbankname.
// Create connection to Database
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
mysqli_set_charset ($mysqli,"utf8");
if(mysqli_connect_errno()){
echo "Verbindung fehlgeschlagen: ".mysqli_connect_error();
}
else {
echo "success";
}
The connetion runs without any problem.
if ($select_stmt = $mysqli->prepare("SELECT name FROM accounts WHERE id = 1")) {
$select_stmt->execute();
$select_stmt->store_result();
$select_stmt->bind_result($name);
$select_stmt->fetch();
}
else {
echo $mysqli->error();
}
echo "Name: " . $name;
Selecting the name of the aacount database is also running without a problem with binding the id directly in the sql query.
The problem comes up with binding the id with $select_stmt->bind_param()
if ($select_stmt = $mysqli->prepare("SELECT name FROM accounts WHERE id = ?")) {
$select_stmt->bind_param('s', '1');
$select_stmt->execute();
$select_stmt->store_result();
$select_stmt->bind_result($name);
$select_stmt->fetch();
}
else {
echo $mysqli->error();
}
echo "Name: " . $name;
The behaviour is like the one in an infinit loop.
But echo "Name: " . $name;
is not displayed at all. The echo $mysqli->error();
as well.