I know there have been a lot of question with the same topic, but i am just not able to find my mistake.
I create a function:
function getLicenseType($computerid){
$stmt = $GLOBALS['pdo'] -> prepare("SELECT * FROM :tabelle WHERE computerid = :id");
$stmt->bindParam("id",$computerid);
$stmt->bindParam("tabelle",$GLOBALS['licensetable']);
$stmt->execute();
$licenseinfo = $stmt->fetch();
if ($licenseinfo != false )
{
return $licenseinfo['licensetype'];
}
else
{
return "NoLicense";
}
}
The error:
Fatal error: Uncaught exception 'PDOException' with message '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 ''backuplicenses' WHERE computerid = '40'' at line 1' in api.php:42 Stack trace: #0 api.php(42): PDOStatement->execute() #1 license.php(10): getLicenseType('40') #2 {main} thrown in api.php on line 42
I checked all variables but they are not null. So that can´t be the problem.