带有“id”的php插入问题

fwzugrvs  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(271)

我正在尝试解决一个应用程序的问题。最初,由于php从php5升级到php7,我们遇到了问题。这似乎在某些地方得到了纠正,但现在我又遇到了问题。
有人能检查一下语法,看看输入是否正确吗?

if($_POST['create_special_appointment']){ 
    $customer_id   = htmlspecialchars($_POST['customer'], ENT_QUOTES);
    $category_id   = htmlspecialchars($_POST['category'], ENT_QUOTES);
    $start_date    = htmlspecialchars($_POST['start_date'], ENT_QUOTES);
    $end_date      = htmlspecialchars($_POST['end_date'], ENT_QUOTES);
    $start_time = htmlspecialchars($_POST['start_time'], ENT_QUOTES);
    $end_time   = htmlspecialchars($_POST['end_time'], ENT_QUOTES);
    $booked_for =  post_array_to_explode($_POST['booked_for']);
    $notes      = htmlspecialchars($_POST['notes'], ENT_QUOTES);
    $session_id = htmlspecialchars($_POST['session_id'], ENT_QUOTES);
    $time       = date("Y-m-d H:i:s");
    $agent_id   = get_agent_from_session($session_id, 'id');

    //if(!($start_time)){$start_time = '00:00';}
    //if(!($end_time)){$end_time = '00:00';}
    //$start_date = $start_date.' '.$start_time;
    //$end_date = $end_date.' '.$end_time;

    $date=date('Y-m-d',strtotime($date));
    $start_date = $start_date.' '.$start_time.":00";
    $end_date = $end_date.' '.$end_time.":00";

    //$start_date = format_datetime_mysql($start_date);
    //$end_date = format_datetime_mysql($end_date);

    $insert = $dbh->exec("INSERT INTO calendar_special(start_date, end_date, notes, category_special_id, added_by, booked_for, date_added, customer_id) VALUES ('$start_date', '$end_date', '$notes', '$category_id', '$agent_id', '$booked_for', '$time', '$customer_id')");
    if($insert){
        $notification_msg[] = array(type=>'alert-success', h4=>'Success!', msg=>'Appointment Created');
        header('Location: ' . $_SERVER['HTTP_REFERER']);
    }else{
        $notification_msg[] = array(type=>'alert-warning', h4=>'Warning!', msg=>'Appointment NOT Created');
        mysqli_error($con);
        var_dump($_REQUEST);
        print_r($dbh->errorInfo());
    }
    //temp-code
    //var_dump($insert);
}

实际形式代码为:

<select name="customer" id="customer-single" style="width:100%"> 
        <option value="">Select a customer (Optional)</option>
        <?php  foreach(customer_array($ajax['0']) as $customer){ ?>
            <option value="<?php echo $customer['id'] ?>">
        <?php echo $customer['business_name'] ?> - <?php echo $customer['first_name'] ?> <?php echo $customer['last_name'] ?></option>
        <?php } ?>
</select>

我得到的错误是:
“警告!“未创建约会”
数组(11){[“会话id”]=>字符串(64)“c5ec66786328e97af8f8fb6771912b58c5869986816b3d2bc9916b7e740cff44”[“创建特殊约会”]=>字符串(4)“真”[“客户”]=>字符串(0)”[“类别”]=>字符串(1)“1”[“开始日期”]=>字符串(10)“2018-10-23”[“开始时间”]=>字符串(5)“10:35”[“结束日期”]=>字符串(10)“2018-10-31”[“结束时间”]=>string(5)“10:35”[“booked\u by”]=>string(1)“5”[“booked\u for”]=>数组(1){[0]=>string(2)“71”}[“notes”]=>string(18)“paul holiday test”}数组([0]=>22007[1]=>1366[2]=>第1行“customer\u id”列的整数值“”不正确)
抱歉,如果这个问题的措辞有误,如果是这样,请告知。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题