我卡住了現在作爲我的更新和插入查詢不工作,選擇查詢工作非常好。更新並插入查詢不工作從php
這裏是我下面的代碼...
<?php
if(isset($_POST['save'])){
$exam_type=$_POST['exam_type'];
$exam_from=$_POST['exam_from'];
$exam_to=$_POST['exam_to'];
$total_points=$_POST['total_points'];
$passing_grade=$_POST['passing_grade'];
$time_limit=$_POST['hrs']*360 + $_POST['min']*60;
$cid=$_GET['cid'];
$sql = $con->prepare("UPDATE new_oes.exam"
. " SET exam_type=?,exam_from =?, exam_to=?,"
. "modified_by=?,passing_score=?, time_limit=?,passing_grade=? "
. "WHERE exam_type = ? AND cid =? ");
$sql->execute(array($exam_type, $exam_from, $exam_to, $username,
$total_points, $time_limit, $passing_grade, $exam_type,$cid)) or die(mysqli_error($con));
// echo $result1;
// $this->query($sql);
if(mysqli_affected_rows($con)>0){
echo "<script type='text/javascript'>alert('Exam Updated!!!')</script>";
exit;
} else{
echo "An error occurred, try again later!!!";
}
}
?>
請與錯誤幫幫我!
注:查詢從phpMyAdmin的工作
是這樣的mysqli或PDO? – RamRaider
$ username在哪裏設置? –
@NigelRen $用戶名來自會話,在此代碼之前的某處設置。建議將其設置到if語句中? – akinlex