0

How can i put my variable $table into query $query = $connect->connexion()->prepare('SELECT * FROM :tableR'); $query->bindParam(":tableR",$tableType); $query->execute();

loi219
  • 238
  • 1
  • 5
  • 13
  • 2
    http://stackoverflow.com/questions/15990857/reference-frequently-asked-questions-about-pdo#15991422 – Your Common Sense Nov 22 '13 at 10:57
  • You cannot bind the actual tablename (or column names for that matter) as the SQL is prepared (ie: validated) prior to the values being bound.You Could build the SQL String by concatening the table name and using that string for the prepare and then bind the other values ... BUT.... If you do this you need to protect youself against SQL Injection – Adrian Cornwell Nov 22 '13 at 13:08
  • I rewrite my application, and i don't use PHP variables – loi219 Nov 25 '13 at 13:54

0 Answers0