我无法弄清楚为什么我的php脚本在删除数据库表中的所有数据后有时无法正常工作
<?php
$con = mysqli_connect("localhost","root","","db_csbn");
if(mysqli_connect_errno())
{
echo "MySQLi Connection was not established: " . mysqli_connect_error();
}
?>
...
<?php
include "connect.php";
$tor = (isset($_POST['tor']) ? "1" : "0");
$frm = (isset($_POST['frm']) ? "1" : "0");
$dp = (isset($_POST['dp']) ? "1" : "0");
$gm = (isset($_POST['gm']) ? "1" : "0");
$hd = (isset($_POST['hd']) ? "1" : "0");
$cr = (isset($_POST['cr'])? "1" : "0");
$ch = (isset($_POST['ch']) ? "1" : "0");
$snumber = $_POST['snumber'];
$documents = $tor.$frm.$dp.$gm.$hd.$cr.$ch;
echo $documents;
$date = date("Y-m-d");
if($tor || $frm || $dp || $gm || $hd || $cr || $ch)
{
$id = str_replace("-","",$date).$snumber;
$sql = "INSERT INTO `tbl_requests` (`id`, `dr`, `snumber`, `date`) VALUES('".$id."', '".$documents."', '".$snumber."', '".$date."');";
if( mysqli_query($con, $sql))
{
echo"<script>alert(Request id (Please Save):\n $id);</script>";
}
}
}
?>
运行此脚本后我看不到任何错误,但没有数据添加到我的表中。
答案 0 :(得分:-1)
首先,你有太多}
query
else
后printf("Error: %s\n", mysqli_error($link));