-2

It is working

$result = $conn->prepare("SELECT * FROM questions");
$result->execute();

But this not

$result = $conn->prepare("SELECT * FROM (?)");

$result -> bind_param("s", $name_tb);

$name_tb = "questions";
$result->execute();

The error is:

Call to a member function bind_param() on boolean

Farid S
  • 49
  • 7

1 Answers1

0

This won't work.

It is actually not possible to bind table names. You can only bind query parameters. What you can do is something like:

$table = "TABLENAME";
query($table);

function query($table) {
    $sql = "SELECT * FROM $table";
}

For sure you have to edit the content of the function that it'll work. Its just to show you an example. But keep in mind: No tablenames. Only parameters with bind.

Twinfriends
  • 1,972
  • 1
  • 14
  • 34