มันขึ้น Error แบบนี้ค่ะ Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Project1\admin\get-answer.php on line 55 ช่วยตรวจดูให้หน่อยค่ะ
Code (PHP)
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<body bgcolor="#FFFACD">
<div align="center">
<!--<p><img src="หัวเว็บ.png" width="1113" height="203" /></p>-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
//$answer = $_POST['1'];
//echo $answer;
$score=0;//เก็บคะแนน
$numChoice=1;
/*foreach($_POST as $choice=>$answer){
echo $choice,"ตอบ",$answer,'<br>';
}*/
foreach($_POST as $choice=>$answer)
{if($choice!='button')
{$sql="Select T_id From test Where T_id={$choice} and T_anwser={$answer}";
$rs = mysql_query($sql);
if(mysql_num_rows($rs)==1)//แสดงว่าตอบถูก
{$score++;//ถ้าตอบถูกได้คะแนน
}
echo 'ข้อ : ',$numChoice,' ตอบ ', $answer,'<br/>';
$numChoice++;
}
}
$pass='เสียใจด้วยคุณไม่ผ่านการทดสอบ ';
if($score>=5){
$pass='ดีใจด้วยคุณผ่านการทดสอบ ';
}
echo 'คะแแนนที่ทำได้ ' , $score,' คะแนน ';
echo '<br/> ผลการทดสอบ: ',$pass;
?>
<?php
require_once('../Connections/MyConnec.php');
mysql_select_db($database_MyConnec, $MyConnec);
echo $strSQL = "INSERT INTO score(St_id, St_score) VALUES ('$_REQUEST[St_User]',$score)";
//echo "INSERT INTO `score`(`St_id`, `St_score`) VALUES ($POST['St_User'],$score)";
$objQuery = mysql_query($strSQL);
?>
<br />
<br />
<br />
<br />
<a href="<?php echo $logoutAction ?>"><font face="Angsana New"><h1>ออกจากระบบ</h1></font></a>
</body>
</html>
Tag : PHP, MySQL
Date :
2017-03-22 15:19:59
By :
Tarnikar
View :
1898
Reply :
2
บรรทัดนี้
$rs = mysql_query($sql);
เพิ่มต่อเป็น
$rs = mysql_query($sql);
echo mysql_error();
จะทราบว่า error เกี่ยวกับอะไรครับ
Date :
2017-03-22 16:39:48
By :
num
Date :
2017-03-22 16:46:57
By :
Tarnikar
Load balance : Server 05