I can't get bindValue to bind my values to the sql query.
$sql = "INSERT INTO :table(:columns) VALUES(:values)";
$query = $conn->prepare($sql);
$query->bindValue(':table',$table);
$query->bindValue(':columns',$columns);
$query->bindValue(':values',$values);
$query->execute();
When I run this, $query->execute() returns "false" and the data isn't update to the DB. I've also tried:
$sql = "INSERT INTO :table(:columns) VALUES(:values)";
$query = $conn->prepare($sql);
$query->execute(array('table'=>$table,':columns'=>$columns,':values'=>$values));
and it still doesn't work.
This works but isn't what I want to do:
$sql = "INSERT INTO $table($columns) VALUES($values)";
$result = $conn->query($sql);
Please tell me what I'm doing wrong. Thanks.