Php MySQLi Prepare语句未插入数据库表

Php MySQLi Prepare语句未插入数据库表,php,mysqli,prepared-statement,Php,Mysqli,Prepared Statement,我正试图使用MySQLi prepare语句将值插入到我的OpenJobs表中。我有4个复选框,相当于4个不同的工作。如果标记了一个或多个复选框,我希望将相应的jobid插入表中。以下是我迄今为止编写的代码: <form id="frmSelStore" method="post" action ="<?php $restaurantid = $_POST['ddlStore']; $jobtype = $_POST['jobs']; if($stmt = mysqli_prepa

我正试图使用MySQLi prepare语句将值插入到我的OpenJobs表中。我有4个复选框,相当于4个不同的工作。如果标记了一个或多个复选框,我希望将相应的jobid插入表中。以下是我迄今为止编写的代码:

<form id="frmSelStore" method="post" action ="<?php 
$restaurantid = $_POST['ddlStore'];
$jobtype = $_POST['jobs'];
if($stmt = mysqli_prepare($mysqli,'Insert into OpenJobs values $restaurantid, $jobtype'))
{
    mysqli_stmt_bind_param($restaurantid,$jobtype);
    mysqli_stmt_execute($stmt);
    echo '$jobtype was posted for Store $restaurantid';
    mysqli_stmt_close($stmt);
}

?>">

您的insert查询语句似乎格式不正确

尝试更改:

Insert into OpenJobs values $restaurantid, $jobtype
最低限度:

Insert into OpenJobs values ($restaurantid, $jobtype)
我的建议是:

insert into `OpenJobs` (`restaurantid`, `jobtype`) values ($restaurantid, $jobtype)

请注意:区分大小写也会导致问题,具体取决于您的配置方式(例如OpenJobs vs.OpenJobs vs.OpenJobs)。

我使用了您的第三个建议如下:if($stmt=mysqli_prepare($mysqli,'Insert into
OpenJobs
restaurantid
jobtype
)值$restaurantid,$jobtype');但是,也会出现相同的结果。
值周围仍然缺少括号。您应该有
值($restaurantid,$jobtype)
Insert into OpenJobs values $restaurantid, $jobtype
Insert into OpenJobs values ($restaurantid, $jobtype)
insert into `OpenJobs` (`restaurantid`, `jobtype`) values ($restaurantid, $jobtype)