Php MySQL——致命错误:对非对象调用成员函数bind_param()

Php MySQL——致命错误:对非对象调用成员函数bind_param(),php,mysql,sql,create-table,prepare,Php,Mysql,Sql,Create Table,Prepare,我已经搜索了这篇文章标题几乎相同的几十个问题,但我还没有找到我具体问题的答案。我试图准备一份声明,但每次都会出现这个错误。我在想,我的sql语法肯定有一些错误,但我一生都找不到 $title = "this_is_my_table_title"; //import the database login credential variables require("localhost_credentials.php"); $conn = new mysqli($db_servername

我已经搜索了这篇文章标题几乎相同的几十个问题,但我还没有找到我具体问题的答案。我试图准备一份声明,但每次都会出现这个错误。我在想,我的sql语法肯定有一些错误,但我一生都找不到

$title = "this_is_my_table_title";    

//import the database login credential variables
require("localhost_credentials.php");

$conn = new mysqli($db_servername, $db_username, $db_password, $db_name);
if($conn->connect_error)
{
    die("Connection failed: " . $conn->connect_error);
}

$querystr  = "CREATE TABLE ? (";
$querystr .= "id int(11) not null auto_increment,";
$querystr .= "section varchar(255) not null,";
$querystr .= "raw_content LONGTEXT not null,";
$querystr .= "formatted_content LONGTEXT not null,";
$querystr .= "primary key (id)";
$querystr .= ");";


$statement = $conn->prepare($querystr);  <--- error here
$statement->bind_param("s", $title);
$statement->execute();
$statement->close();
$title=“这是我的表格标题”;
//导入数据库登录凭据变量
需要(“localhost_credentials.php”);
$conn=newmysqli($db\u服务器名,$db\u用户名,$db\u密码,$db\u名称);
如果($conn->connect\u错误)
{
die(“连接失败:”.$conn->connect\U错误);
}
$querystr=“创建表?”;
$querystr.=“id int(11)非空自动增量,”;
$querystr.=“节varchar(255)不为空,”;
$querystr.=“原始内容长文本不为空,”;
$querystr.=“格式化内容长文本不为空,”;
$querystr.=“主键(id)”;
$querystr=”;“;
$statement=$conn->prepare($querystr);绑定参数(“s”,$title);
$statement->execute();
$statement->close();

不能将占位符用作表名,它只能用于替换表达式。因此
创建表?
无效。使用:

$querystr  = "CREATE TABLE `$title` (";

验证
$title
是否为可接受的表名后。

prepare
返回
false
时,执行
echo$conn->error
查看SQL错误消息啊,好的。我不知道,我想我可以在任何地方使用占位符。谢谢这就解决了,这是一个常见的误解。