我对 PHP 非常熟悉,但这是我第一次使用 mysqli 库。我试图在数据库中插入一行,但它只是没有插入。我的代码如下所示(为安全起见更改了数据库登录详细信息):
... // $_REQUEST variables processed
$oConn = new mysqli("localhost","user","password","mydatabase") or die("Error " . mysqli_error($oConn));
$rProvider = $oConn->query("select * from providers where id = $iProviderID");
$aProvider = mysqli_fetch_array($rProvider);
// $aProvider has all the information from the provider that I wanted, so my database connection is working
$oConn->query("insert into bookings (provider_id, provider_rates_id, secret, preferred_date, alternate_date, adults, children, transfer_required, firstname, lastname, email, phone, comments) values
($iProviderID, $iRatesID, $sSecret, '$sDate', '$sAltDate', $iAdults, $iChildren, $iTransfer, '$sFirstNameSQL', '$sLastNameSQL', '$sEmailSQL', '$sPhoneSQL', '$sCommentsSQL'");
$iBookingID = $oConn->insert_id;
我没有收到错误,$iBookingID 为 0。该行只是没有插入到数据库中。我浏览了 StackExchange 上的 PHP 手册和类似帖子,但无法解决此问题。