this is already asked million times already, but I got this error while creating a database in php using pdo. Below is the part that causes this error.
try {
$conn = new PDO("mysql:host=$servername", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// create database
$db_query = $conn->prepare("CREATE DATABASE IF NOT EXISTS ?");
$db_query->execute([$myDB]);
} catch(PDOException $e) {
echo "<br>" . $e->getMessage();
}
I could create the database just fine without using prepare, so I wonder if prepare cannot be used to create database by design.