0

mysql テーブルにデータを挿入しようとしていますが、プロセスが完了せず、エラーに対して何も出力されません。エラーを正しく出力しているとは思いません。php.net を見ると、エラー処理を適切に行っているように見えますが、何か不足している可能性があります。

ここにコードがあります

$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$sqlInsert = $db->query("INSERT INTO transactions(`user_id`, `courses`, `invoice`, `start_date`, `end_date`, `mc_gross`, `email`) VALUES ('".$user_id."','".$trim."','".$invoice."','".$start_date."','".$end_date."', '".$email."')");


if($sqlInsert)
    {
    echo "Inserted successfully";
    }
    else
      {
       printf("Error: ", $db->error);

       }

変数の値は次のとおりです。

$custom = $_SESSION['custom'];
$user_id = $_POST['userID'];
$pwd = $_POST['password'];
$email = $_POST['email'];
$start_date = date('Y-m-d');
$end_date = date (('Y-m-d'), strtotime('+120 days'));
$invoice = date('Ymd'). mt_rand(1252,10000);
$invoice_check = $db->query("SELECT `invoice` FROM `transactions` WHERE `invoice` = $invoice");
while ($rows = $invoice_check->fetch_assoc())
{
    $invoice = date('Ymd'). mt_rand(1252,10000);   
}
$mc_gross = $_SESSION['subtotal'];
$trim = rtrim($custom, ",");

$trim の var_dump はstring(17) "bio_01,calculus_01"あり、他の変数は期待どおりに正常にエコーアウトします。

何か案は?

編集$sqlInsert の代わりに $db でコードを更新しました。エラーの出力はまだありません。

4

1 に答える 1