รบกวนช่วยดูโค้ดให้ทีค่ะ ตรงหน่วยงาน กับตำแหน่งมันerror ว่า Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ...
Code (PHP)
<?php
session_start();
include("connect.php");
include("inc/function.php");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="navbar section" id="navbar">
<div class="widget Navbar" id="Navbar1">
<div></div>
</div>
</div>
<table width="915" height="150
" border="0" align="center" background="images/head.jpg">
<tr>
<th width="450" height="150" scope="col"> </th>
</tr>
</table><br>
<table width="915" height="319" border="0" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<th height="28" align="left" valign="top" bordercolor="#97FF97" bgcolor="#97FF97" scope="col"><table width="896" height="37" border="0" align="center" bordercolor="#97FF97" bgcolor="#97FF97">
<tr>
<th width="890" height="18" align="center" bgcolor="#97FF97" scope="col">
<span class="font"><a href="repair.php">หน้าหลัก</a> |
<a href="detail_Building.php">เกี่ยวกับฝ่ายอาคารสถานที่</a> |
<a href="logout.php">ออกจากระบบ</a></span> </th>
</tr>
</table>
<p></p>
<p></p>
<p> </p>
<div align="right"></div>
<div align="right"></div>
<div align="right"></div></th>
</tr>
<tr>
<th height="276" align="left" valign="top" bgcolor="#FFFFFF" scope="col">
<div align="right"><span class="font">ยินดีต้อนรับคุณ </span>
<span class="font3"><? echo $_SESSION['Emp_Fname']; ?></span><img src="images/friend.gif" width="24" height="24" align="absmiddle" /> </div>
<br>
<div>
<div align="right"class="font">วันที่
<span class="font3"><?php
$_month_name = array("01"=>"มกราคม", "02"=>"กุมภาพันธ์", "03"=>"มีนาคม",
"04"=>"เมษายน", "05"=>"พฤษภาคม", "06"=>"มิถุนายน",
"07"=>"กรกฎาคม", "08"=>"สิงหาคม", "09"=>"กันยายน",
"10"=>"ตุลาคม", "11"=>"พฤศจิกายน", "12"=>"ธันวาคม");
$vardate=date('Y-m-d');
$yy=date('Y');
$mm =date('m');$dd=date('d');
if ($dd<10){
$dd=substr($dd,1,2);
}
$date=$dd ." ".$_month_name[$mm]." ".$yy+= 543;
echo $date;
?></span></div>
<table width="905" height="151" border="0">
<tr>
<th width="74" height="147" align="center" scope="col"> </th>
<th width="821" align="center" valign="top" scope="col"><p><?php
if($_GET['method']=='viewTask'){
?>
<?PHP
if($_SESSION["Agencies_ID"]==0){
$_sql = "SELECT * FROM employee WHERE Emp_ID='".$_SESSION["empid"]."' ";
}else{
$_sql = "SELECT * FROM applicant WHERE App_ID='".$_SESSION["appid"]."' ";
}
$result = mysql_query($_sql);
$row = mysql_fetch_array($result);
$_sql = "SELECT * FROM repair WHERE gencode='".$_GET['repair_id']."' ";
$_re = mysql_query($_sql);
$_datax = mysql_fetch_array($_re);
$_sql ="SELECT * FROM worktype WHERE WorkType_ID = '".$_datax['WorkType_ID']."'";
//echo $_sql;
$_re = mysql_query($_sql);
$_d = mysql_fetch_array($_re);
?>
<table width="909" height="92" border="0" align="center">
<tr>
<th width="568" height="109" valign="top" scope="col"><img src="images/logo.jpg" width="117" height="88" align="absmiddle" /> </th>
<th width="331" align="left" valign="top" scope="col"><div class="font">แบบฟอร์มการขอใช้บริการซ่อมบำรุง</div>
<div class="font6">[<?=$_d['WorkType_Name']?>] <span class="font"><?=$_d['WorkType_ID']?></span></div>
<div class="font">ฝ่ายอาคารสถานที่ มก.ฉกส.</div>
<div class="font">โทร 042-725089 โทรสาร 042-725088</div>
<div class="font">สายด่วน 1600-1605</div>
<p> </p></th>
</tr>
</table>
<table width="875" height="280" border="0" align="center" bgcolor="#FFFFFF" style="border:solid 0px; bordercolor="#ffffff">
<tr>
<td width="145" height="33"><div align="right" id='testSys'><span class="font7">รหัสผู้ขอใช้บริการ</span><span class="font"> : </span></div></td>
<td colspan="3"><div align="left" class="font"><? echo $row[0];?><input type='hidden' name='app_id' value='<? echo $row[0];?>'> </div></td>
</tr>
<tr>
<td height="26"><div align="right" ><span class="font7">คำนำหน้าชื่อ</span><span class="font"> : </span></div></td>
<td colspan="3"><div align="left" class="font"><? echo $row[1];?></div></td>
</tr>
<tr>
<td height="30"><div align="right" ><span class="font7">ชื่อ</span><span class="font"> : </span></div></td>
<td width="224"><div align="left" class="font"><? echo $row[2];?></div></td>
<td width="269"><div align="left"><span class="font7">สกุล</span> : <span class="font"><? echo $row[3];?></span> </div></td>
<td width="219"> </td>
</tr>
<tr>
<td height="26"><div align="right" ><span class="font7">หน่วยงาน</span><span class="font"> : </span></div></td>
<td><div align="left" class="font"><?
$_sql = "SELECT * FROM agencies WHERE Agencies_ID=".$_SESSION["Agencies_ID"]." ";
// echo $_sql;
$_re = mysql_query($_sql);
$_data = mysql_fetch_array($_re);
echo $_data['AgenciesName'];
?></div></td>
<td><div align="left" class="font"><span class="font7">ตำแหน่ง</span> :
<?
$_sql = "SELECT * FROM position WHERE Position_ID =".$_SESSION["Position_ID"]."";
// echo $_sql;
$_re = mysql_query($_sql);
$_data = mysql_fetch_array($_re);
echo $_data[PositionName] ;
?></div></td>
</tr>
<tr>
<td height="31"><div align="right" ><span class="font7">โทรศัพท์ (มือถือ)</span><span class="font">:</span></div></td>
<td><div align="left" class="font"><? echo $row[4];?></div></td>
<td colspan="2"><div align="left" class="font"><span class="font7">โทรศัพท์(ภายใน) </span>: <? echo $row[5];?></div></td>
</tr>
<tr>
<td height="35"><div align="right" ><span class="font7">อาคาร</span><span class="font"> :</span></div></td>
<td colspan="3"><div align="left" class="font">
<?PHP
$_re = mysql_query("SELECT * FROM building WHERE Building_ID=".$_datax['Building_ID']." ");
$_b = mysql_fetch_array($_re);
echo $_b['Building_Name'];
?> </div></td>
</tr>
<tr>
<td width="145" height="32"><div align="right" ><span class="font7">หมายเลขห้อง</span><span class="font"> : </span></div></td>
<td><div align="left" class="font">
<?PHP
$_sql = "SELECT * FROM room WHERE Room_ID=".$_datax['Room_ID']." AND Building_ID=".$_datax['Building_ID']." ";
// echo $_sql;
$_re = mysql_query($_sql) or die(mysql_error());
$_b = mysql_fetch_array($_re);
echo $_b['RoomName'];
?>
</div></td>
<td><div align="left" class="font"><span class="font7">ชั้น</span> :
<?=$_datax['Room_ID']?>
</div>
<div align="left"></div></td>
</tr>
<tr>
<td height="29"><div align="right" ><span class="font7">ให้ไปซ่อมในวันที่ </span><span class="font">: </span></div></td>
<td><div align="left" class="font"><?PHP echo $_datax['Re_Begin']; ?></div>
<div align="left"></div></td>
<td colspan="2"><div align="left" class="font"><span class="font7">ระหว่างเวลา</span>:<?=$_datax['Re_Time']?>
<span class="font7"> ถึง</span><?=$_datax['Re_EndTime']?>
</span></span></span></div></td>
</tr>
</table>
<?PHP
$_p = explode("@",$_datax['Re_Cause']);
// print_r ($_p);
echo "<br> <span class=font6>รายละเอียด </span>
<table width=600'>
<tr><td colspan=2 class=font8>".$_p[0]." </td></tr>
<tr><td height=100% class=font1></td>
<td class=font1> ".$_p[1]."</td></tr>
</table>";
} ?>
ตรงหน่วยงาน กับตำแหน่งมันerror ว่า
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\repair\view_repair.php on line 168
ช่วยดูให้ทีค่ะว่ามันผิดตรงไหนTag : PHP
Date :
2011-04-24 16:47:08
By :
-
View :
739
Reply :
2
Code (PHP)
$_sql = "SELECT * FROM room WHERE Room_ID='".$_datax['Room_ID']."' AND Building_ID='".$_datax['Building_ID']."' "
ใส่เครื่องหมาย 'xxxx' ด้วยครับ เผื่อไม่มีค่าจะได้ไม่ Error
Date :
2011-04-24 20:50:40
By :
webmaster
ขอบคุณค่ะ
Date :
2011-04-27 01:57:49
By :
l3uil3ui
Load balance : Server 02