Notice: Undefined offset: 1 in /var/www/localhost/htdocs/contactdb/add-job-bork.php on line 34
我收到上述错误,数据无法访问数据库。我试过但是没有运气
<?php
$host = "localhost";
$user = "custdb";
$pass = "";
$db = "accounting";
session_start();
$odb = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
$odb->setAttribute(PDO::ATTR_CASE, PDO::ERRMODE_EXCEPTION);
//insert job
if (isset($_POST['invoice_num'])) {
$cust_id = $_SESSION['id'];
$date_order = $_POST['date_order'];
$invoice_num = $_POST['invoice_num'];
$q = "INSERT INTO orders (cust_id,date_order, invoice_num)
SELECT * FROM (SELECT :cust_id,:date_order, invoice_num) as tmp WHERE NOT EXISTS (SELECT invoice_num FROM orders WHERE invoice_num = :invoice_num)
LIMIT 1;";
$query = $odb->prepare($q);
$results = $query->execute(array(
":cust_id" => $cust_id,
":date_order" => $date_order,
":invoice_num" => $invoice_num
));
}
?>
<?php
$cust_info = $_SESSION['id'];
$pieces = explode(":", $cust_info);
$_SESSION['id'] = $pieces[0];
if (isset($pieces[1])) {
$_SESSION['cust_name'] = $pieces[1];
}
?>
<div class="">
<form method="post" action"">
<label> Order date:</label>
<input type="text" id="date_order" name="date_order"/> <br />
<input type="text" id="invoice_num" name="invoice_num"/> <br />
<input type ="submit" value"Submit" /> <br /> <br />
</form>
</div>
</body>