PHP PDO variable insertion incompatible with SQLite [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


PHP PDO variable insertion incompatible with SQLite [duplicate]



This question already has an answer here:



when I run the following:


$pdo = new PDO('sqlite:/path/to/database.db');
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $pdo->prepare('CREATE TABLE IF NOT EXISTS :user (id INTEGER PRIMARY KEY AUTOINCREMENT, time INTEGER NOT NULL, ping TEXT NOT NULL);');
$user = "me";
$stmt->execute(array('user' => $user));



I get the following error, referencing the :user part of the SQL:


:user



PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 near ":user": syntax error in /datasql.php:21nStack trace:n#0 /datasql.php(21): PDO->prepare('CREATE TABLE IF...')n#1 {main}n thrown in /datasql.php on line 21



I can't find anything wrong with the SQL and if I run the command without the variable insertion, it runs fine.



What is causing this error?
Thanks ahead!



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





you can't bind a table (or column).
– Funk Forty Niner
yesterday







Thanks, you're right... That was impossible to find with google...
– HelpingHand
yesterday





You're welcome.
– Funk Forty Niner
yesterday




Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP