I made this code to create databases :
public function addDatabase($name, $collation) {
try {
$sql = "CREATE DATABASE ':name' COLLATE ':collation';";
// Prepare the query to execute
$query = $this->db->prepare($sql);
$parameters = array(':name' => $name, ':collation' => $collation);
// Execute the query
$query->execute($parameters);
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
}
It was not displaying any errors and no results ... I refined the code without bind
public function addDatabase($name, $collation) {
try {
$sql = "CREATE DATABASE '$name' COLLATE '$collation';";
// Prepare the query to execute
$query = $this->db->prepare($sql);
// Execute the query
$query->execute();
} catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}
}
And without bind worked. But I can not leave without bind to avoid SQL injection .