I am trying to learn PHP and as part of this am writing a small setup script. I have written one before and it worked, however, I have now written a multistage setup.php
script and am getting a syntax error when executing the following prepared MySQL statement:
$sql = $connection->prepare( "CREATE DATABASE IF NOT EXISTS ?" );
$sql->execute( array( $database_name ) );
Where $database_name
is provided by a form. I have done a var_dump
on $database_name
and it has the value I provide to it by the form. However, when executing the statement, I get the following error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "cv_database" at line 1
Does anyone have any idea what could be causing this?