Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a9501045/public_html/checkuser.php on line 65
เกิด error ขึ้นตามภาพเลยครับ
นี่โค๊ดผมครับ
และนี่เป็น ดาตาเบสผมครับ วอนผู้รู้แก้ให้ทีครับ จนปัญญาจริงๆตอนนี้<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>checkuser</title>
<!-- InstanceEndEditable -->
<link href="../mystyle.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>
<div align="center">
<!-- head web -->
<div id="header"></div>
<!-- alldata -->
<div id="data">
<div id="box">
<!-- left data -->
<div id="left">
<!-- linking -->
<div id="link">
<h1 class="tabcolor"><a href="../index.php">หน้าแรก</a></h1>
<h1 class="tabcolor"><a href="../time.php">วันเวลา</a></h1>
<h1 class="tabcolor"><a href="../datatype.php">ชนัดตัวแปล</a></h1>
<h1 class="tabcolor"><a href="../settype.php">การแปลงชนิดของข้อมูล</a></h1>
<h1 class="tabcolor"><a href="../homework.php">การบ้าน</a><br />
<br />
<br />
</h1>
</div>
<!-- end linking -->
</div> <!-- end leftdata-->
<div id="right" align="center"><!-- InstanceBeginEditable name="content" -->
<div id="content" >
<?php
$username = $_POST[username];
$password = $_POST[password];
$con = mysql_connect("mysql6.000webhost.com","a9501045_hr","hr1234");
if(!$con)
{ echo "Can not connect"; }
mysql_select_db("hr",$con);
mysql_query("SET NAMES UTF8");
$result = mysql_query("select name,surname from emp where username = '$username' and password = '$password';");
$num = mysql_num_rows($result); บรรทัดนี้เลยครับที่เป็นปัญหา
if($num <=0)
{
echo "ไม่พบชื่อผู้ใช้นี้ในฐานข้อมูล";
echo "<meta http-equiv='refresh' content='2;URL=login.html' />";
}
else
{
echo "กำลังตรวจสอบผู้ใช้";
$_SESSION["userid"] = session_id();
$_SESSION["username"] = $username;
while ($data = mysql_fetch_array($result) )
{
$_SESSION["name"] = $data[name];
$_SESSION["surname"] =$data[surname];
}
echo "<meta http-equiv='refresh' content='2;URL=main.php' />";
}
?>
</div>
<!-- InstanceEndEditable -->
<!-- end content-->
</div>
<!-- end right-->
</div> <!-- end box-->
</div> <!-- end data -->
</div>
</body>
<!-- InstanceEnd --></html>