伙计们,我想从文本框等提交数据到我的数据库..我保留了一个弹出框,说提交..into数据库..当我执行它时说输入数据库但数据库是空的.. < / p>
<?php
include('airlineDB2.php');
$nameb1 = @$_POST['nameb1'];
$ageb1 = @$_POST['ageb1'];
$genderb1 = @$_POST['genderb1'];
$prefb1 = @$_POST['prefb1'];
$planeno = @$_POST['planeno'];
$pdate = @$_POST['pdate'];
if (isset($_POST['book'])) {
//The data is entered into the database here between this
$insert = mysql_query("Insert into ticketbook (planeno,nameb,ageb,genderb,preferenceb,date) VALUES('$planeno','$nameb1','$ageb1','$genderb1','$prefb1','$pdate')");
echo '<script type="text/javascript">alert("Your ticket is booked check your email for further details!")</script>';
//The data is entered into the database here between this
}
?>
答案 0 :(得分:0)
您的查询存在一些错误,您可以将逻辑更改为:
$insert = mysql_query("Insert into ticketbook (planeno,nameb,ageb,genderb,preferenceb,date) VALUES('$planeno','$nameb1','$ageb1','$genderb1','$prefb1','$pdate')");
if ( !$insert ) {
die('Invalid query: ' . mysql_error());
} else if ( mysql_affected_rows()!=1 ) {
die('Error inserting row');
} else {
echo '<script type="text/javascript">alert("Your ticket is booked check your email for further details!")</script>';
};