ช่วยด้วยจ้าาาาาาาาาา Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
ช่วยด้วยจ้าาาาาาาาาา
Quote: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/homeofartp/domains/homeofartphuket.com/public_html/admin_order.php on line 9
โค้ดตามนี้จ้า
Code
<?
session_start();
if ($sess_adminid<>session_id()) {
header( "Location: admin.php"); exit();
}
include "connect.php";
$sql="select * from tb_order ";
$result=mysql_db_query($dbname,$sql);
$number=mysql_num_rows($result);
$no=1;
?>
<!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"><!-- InstanceBegin template="/Templates/index1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>www.homeofartphuket.com</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style2 {
font-size: 12px;
color: #FFFFFF;
}
.style6 {color: #000000; }
.style7 {color: #FFFFFF}
-->
</style>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onload="MM_preloadImages('Asset/test1.png','Asset/HeadLogo2.png')">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="174" height="121" bgcolor="#000000"> </td>
<td width="537" colspan="3" align="center" valign="middle"><p class="style6">Discover your potential of art in your life,welcome to "Home of Art"<span class="style6">,you will have much fun and full of surprise!</span><br />
<a href="www.homeofartphuket.com" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','Asset/HeadLogo2.png',1)"><img src="Asset/Logo1.png" alt="Logo" name="Image8" width="264" height="74" border="0" id="Image8" /></a></p> </td>
</tr>
<tr>
<td height="170" colspan="4"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image7','','Asset/test1.png',1)"><img src="Asset/test.png" alt="www.homeofartphuket.com" name="Image7" width="100%" height="295" border="0" id="Image7" /></a><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','Asset/test1.png',1)"></a></td>
</tr>
<tr>
<td height="35" colspan="4" bgcolor="#000000"><h3><span class="style7">Home | Gallery | Teaching | Order | Contact Us</span></h3></td>
</tr>
<tr>
<td colspan="4" valign="top"><!-- InstanceBeginEditable name="EditRegion1" -->
<?
include "admin_menu.php";
if ($number<>0) {
echo "
<P><B>ใบสั่งซื้อสินค้า</B></P>
<TABLE BORDER=1>
<TR BGCOLOR=#E8E8E8>
<TD><CENTER><B>รหัส</B></CENTER></TD>
<TD><CENTER><B>ชื่อ - สกล</B></CENTER></TD>
<TD><CENTER><B>เบอร์ติดต่อ</B></CENTER></TD>
<TD><CENTER><B>ราคารวม</B></CENTER></TD>
<TD><CENTER><B>[ลบ]</B></CENTER></TD>
</TR> ";
while($rs=mysql_fetch_array($result)) {
$id_order=$rs[id_order];
$code_order=sprintf("%05d",$id_order);
$name_order=$rs[name_order];
$tel_order=$rs[tel_order];
$total_order=$rs[total_order];
echo "
<TR>
<TD><A HREF=\"admin_order_view.php?id_order=$id_order\" TARGET=\"_blank\">$code_order</A></TD>
<TD>$name_order</TD>
<TD>$tel_order</TD>
<TD><CENTER>$total_order</CENTER></TD>
<TD><A HREF=\"admin_order_delete.php?id_order=$id_order\"
onclick=\"return confirm('ยืนยันลบใบสั่งซื้อสินค้า $code_order ออกจากระบบ')\">[ลบ]</A></TD>
</TR>
</TR>";
$no++;
}
echo "</TABLE>";
mysql_close();
}
?>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td width="174" bgcolor="#000000"></td>
<td colspan="3" bgcolor="#B7B7B7"><p class="style2"> Copyright © 2011 Home of Art Phuket. All Rights Reserved. </p>
<p class="style2"> Home of Art (Surin Beach) 20 Srisuntorn road,Chengtalay, Thalang, Phuket,Thailand | Tel +66(0)8547 67714</p></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
Tag : PHP, MySQL, HTML/CSS, Action Script, Ajax, CakePHP
Date :
2011-06-05 12:00:57
By :
rakissara
View :
1201
Reply :
3
ลองเปลี่ยนเป็นแบบนี้ดูครับ
Code (PHP)
<?
session_start();
if ($sess_adminid<>session_id()) {
header( "Location: admin.php"); exit();
}
include ("connect.php");
$result=mysql_query("select * from tb_order ");
//$result=mysql_db_query($dbname,$sql);
$number=mysql_num_rows($result);
$no=1;
?>
Date :
2011-06-05 12:32:01
By :
mangkunzo
หารมีการ include "connect.php"; แล้ว
ตรง
$result=mysql_db_query($dbname,$sql);
เปลี่ยนเป็น
$result=mysql_query($sql); แค่นี้ก็ได้ครับ
Date :
2011-06-05 13:08:32
By :
slurpee55555
ได้แล้วจ้่าขอบคุณมากน๊า ทุกคำแนะนำเลย ^^
Date :
2011-06-05 13:42:16
By :
rakissara
Load balance : Server 05