มัน ERROR แบบนี้นะค่ะ Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Phpbasic\AnimalShop\tesbas.php on line 96
โค๊ดค่ะ
<?
session_start();
?>
<!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=tis-620">
<title>สินค้า</title>
<style type="text/css">
<!--
.style1 { font-size: large;
color: #0000FF;
}
.style3 {color: #0000FF}
.style4 {
color: #0000CC;
font-weight: bold;
font-size: x-large;
}
-->
</style>
</head>
<body>
<?
include"./include/connect.php";
?>
<table width="945" align="center">
<tr bgcolor="#FFFF66">
<td colspan="2" bgcolor="#C7FBBF"><div align="center" class="style1">
<p><img src="image/head.gif" width="973" height="200" /></p>
</div></td>
</tr>
<tr width="17" bordercolor="#000000" bgcolor="#000000">
<td width="22" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p>
<? include"menu.php"; ?>
</p>
</td>
<td width="911" height="460" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p align="center" class="style3"> </p>
<p align="center" class="style4">ค้นหาสินค้า</p>
<center>
<form id="form2" name="form2" method="post" action="tesbas.php">
<table width="546" border="0">
<tr>
<th width="214" scope="col">
<label>
ประเภทคำค้น
<select name="search" id="search">
<option value="1">ชื่อสินค้า</option>
<option value="2">ประเภทสินค้า</option>
<option value="3">ยี่ห้อสินค้า</option>
</select>
</label>
</th>
<th width="344" scope="col">
<label>
<input name="name" type="text" id="name" size="40" maxlength="40" />
</label>
<label>
<input type="submit" name="Submit" value="ค้นหา" />
</label>
</th>
</tr>
</table>
</form>
</center>
<p align="center" class="style4"> </p>
<p align="center" class="style4">ข้อมูลสินค้า</p>
<center> <table width="800" border="1" bordercolor="#00FF00" bgcolor="#FFFFFF">
<tr>
<th scope="row"><strong>รหัสสินค้า</strong></th>
<td><strong>ชื่อสินค้า</strong></td>
<td><strong>รายละเอียด</strong></td>
<td><strong>ราคาทุน</strong></td>
<td><strong>ราคาเงินสด</strong></td>
<td><strong>ราคาเงินเชื่อ</strong></td>
<td><strong>Min Stock</strong></td>
<td><strong>Max Stock </strong></td>
<td><strong>จำนวนคงเหลือ</strong></td>
<td><strong>หน่วย</strong></td>
<td><strong>ยี่ห้อ</strong></td>
<td><strong>ประเภท</strong></td>
<td> </td>
</tr>
<?
$n=0;
$name=$_POST[name];
if($_POST[search]==1){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==2){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pdt_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==3){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.bra_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row==""){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row<>0){
//while($read=mysql_fetch_array($result)){
$Per_Page = 5;
if ( !$Page) {
$Page = 1;
}
$Prev_Page =$Page- 1;
$Next_Page = $Page+ 1;
$result = mysql_db_query($db,$sql);
$Page_start = ( $Per_Page * $Page ) - $Per_Page;
$Num_Rows = mysql_num_rows($result);
if ( $Num_Rows <= $Per_Page )
$Num_Pages = 1;
else if( ( $Num_Rows % $Per_Page ) == 0 )
$Num_Pages = ( $Num_Rows / $Per_Page );
else
$Num_Pages = ( $Num_Rows / $Per_Page ) + 1;
มัน ERROR แบบนี้นะค่ะ Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Phpbasic\AnimalShop\tesbas.php on line 96
<?
session_start();
?>
<!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=tis-620">
<title>สินค้า</title>
<style type="text/css">
<!--
.style1 { font-size: large;
color: #0000FF;
}
.style3 {color: #0000FF}
.style4 {
color: #0000CC;
font-weight: bold;
font-size: x-large;
}
-->
</style>
</head>
<body>
<?
include"./include/connect.php";
?>
<table width="945" align="center">
<tr bgcolor="#FFFF66">
<td colspan="2" bgcolor="#C7FBBF"><div align="center" class="style1">
<p><img src="image/head.gif" width="973" height="200" /></p>
</div></td>
</tr>
<tr width="17" bordercolor="#000000" bgcolor="#000000">
<td width="22" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p>
<? include"menu.php"; ?>
</p>
</td>
<td width="911" height="460" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p align="center" class="style3"> </p>
<p align="center" class="style4">ค้นหาสินค้า</p>
<center>
<form id="form2" name="form2" method="post" action="tesbas.php">
<table width="546" border="0">
<tr>
<th width="214" scope="col">
<label>
ประเภทคำค้น
<select name="search" id="search">
<option value="1">ชื่อสินค้า</option>
<option value="2">ประเภทสินค้า</option>
<option value="3">ยี่ห้อสินค้า</option>
</select>
</label>
</th>
<th width="344" scope="col">
<label>
<input name="name" type="text" id="name" size="40" maxlength="40" />
</label>
<label>
<input type="submit" name="Submit" value="ค้นหา" />
</label>
</th>
</tr>
</table>
</form>
</center>
<p align="center" class="style4"> </p>
<p align="center" class="style4">ข้อมูลสินค้า</p>
<center> <table width="800" border="1" bordercolor="#00FF00" bgcolor="#FFFFFF">
<tr>
<th scope="row"><strong>รหัสสินค้า</strong></th>
<td><strong>ชื่อสินค้า</strong></td>
<td><strong>รายละเอียด</strong></td>
<td><strong>ราคาทุน</strong></td>
<td><strong>ราคาเงินสด</strong></td>
<td><strong>ราคาเงินเชื่อ</strong></td>
<td><strong>Min Stock</strong></td>
<td><strong>Max Stock </strong></td>
<td><strong>จำนวนคงเหลือ</strong></td>
<td><strong>หน่วย</strong></td>
<td><strong>ยี่ห้อ</strong></td>
<td><strong>ประเภท</strong></td>
<td> </td>
</tr>
<?
$n=0;
$name=$_POST[name];
if($_POST[search]==1){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql); $num_row=mysql_num_rows($result); // line 96 ค่ะ
}
else if($_POST[search]==2){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pdt_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==3){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.bra_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row==""){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row<>0){
//while($read=mysql_fetch_array($result)){
$Per_Page = 5;
if ( !$Page) {
$Page = 1;
}
$Prev_Page =$Page- 1;
$Next_Page = $Page+ 1;
$result = mysql_db_query($db,$sql);
$Page_start = ( $Per_Page * $Page ) - $Per_Page;
$Num_Rows = mysql_num_rows($result);
if ( $Num_Rows <= $Per_Page )
$Num_Pages = 1;
else if( ( $Num_Rows % $Per_Page ) == 0 )
$Num_Pages = ( $Num_Rows / $Per_Page );
else
$Num_Pages = ( $Num_Rows / $Per_Page ) + 1;
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
ขอบคุณ คุณ Nico ค่ะ ลองแก้แล้วค่ะ แต่มันก้อ ERROR อีกค่ะ Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Phpbasic\AnimalShop\tesbas.php on line 107