ช่วยดูโค๊ดนี้ให้ผมหน่อยครับ ว่าโครงสร้างมันผิดตรงไหน ตรงบรรทัดที่ 67 เกี่ยวกับ mysql_fecth_array ครับ
Code (PHP)
<?php require_once 'function.inc.php'; ?>
<?php
// ค้นหาและลบการจองที่เกินเวลา ที่ตั้งไว้
$now = mktime(date('H'), date('i'), date('s'), date('n'), date('j'), date('Y'));
$delete_time = date('Y-m-d H:i:s', $now - ($config['reserve_remove_time'] * 3600));
$sql = "SELECT id FROM reserve WHERE reserve_time < '{$delete_time}' AND deposit=0 AND total_cost=0 AND approve=0";
$query = mysql_query($sql) or die($sql);
$delete_ids = array();
while ($row = mysql_fetch_assoc($query))
{
$delete_ids[] = $row['id'];
}
if ($delete_ids)
{
$sql1 = "DELETE FROM reserve WHERE id IN(".join(', ',$delete_ids).")";
$sql2 = "DELETE FROM room_reserve WHERE reserve_id IN(".join(', ',$delete_ids).")";
$sql3 = "DELETE FROM food_reserve WHERE reserve_id IN(".join(', ',$delete_ids).")";
mysql_query($sql1) or die($sql1);
mysql_query($sql2) or die($sql2);
mysql_query($sql3) or die($sql3);
}
?>
<!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>ระบบจองห้องประชุม - หน้าแรก</title>
<link rel="stylesheet" type="text/css" href="media/css/default.css"/>
<script type="text/javascript" src="media/js/jquery-1.4.2.min.js"></script>
<style type="text/css">
<!--
.style2 {font-size: 24px; font-weight: bold; }
-->
</style>
</head>
<body>
<?php header_page(); ?>
<table width="950" bgcolor="#FFFFFF" border="0" align="center" cellpadding="0" cellspacing="0" class="body-border" style="padding: 10px 0 10px 0;">
<tr>
<td width="225" align="center" valign="top" class="right_dash">
<?php login_box(); ?>
<br />
</td>
<td width="707" valign="top" bgcolor="#FFFFCC">
<div align="left">
<?php
$room1 = "select * from room where id = '".$_GET["id"]."'";
$room_sql1 = mysql_query($room1);
$room_sql2 = mysql_fetch_array($room_sql1);
?>
</div>
<table width="15%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#00FF00">
<tr>
<td><div align="center"><?php echo $room_sql2["name"];?></div></td>
</tr>
<tr>
<td><div align="center"><img src="room_picture/<?php echo $room_sql2['picture'];?>" style="float:left; margin: 0 4px 4px 0" /></div></td>
</tr>
</table>
<br />
<?php
$user_sql = "select * from used where room_id ='".$_GET["id"]."'";
$mysql_user = mysql_query($mysql_user);
$mysql_test = mysql_fetch_array($mysql_user);
?>
<div align="center">
<table width="56%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
<tr>
<td bgcolor="#CCFF99"><div align="center" class="style2">วันที่จอง</div></td>
<td bgcolor="#CCFF99"><div align="center" class="style2">ผู้จอง</div></td>
</tr>
<tr>
<td><div align="center"><?php echo $mysql_test["used_day"];?></div></td>
<td><div align="center"><?php echo $mysql_test["name"];?></div></td>
</tr>
</table>
</div>
</div>
<br />
<div align="center"></div></td>
</tr>
</table>
<?php
mysql_close();
?>
<?php footer_page(); ?>
</body>
</html>
ข้อความที่ ERROR
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\meeting_room\history12.php on line 67Tag : PHP, MySQL
Date :
2011-11-07 11:00:30
By :
skynetcom
View :
836
Reply :
2
ใส่ตรงตัวหนาเข้าไปนะครับ
<?php require_once 'function.inc.php'; ?>
<?php
// ค้นหาและลบการจองที่เกินเวลา ที่ตั้งไว้
$now = mktime(date('H'), date('i'), date('s'), date('n'), date('j'), date('Y'));
$delete_time = date('Y-m-d H:i:s', $now - ($config['reserve_remove_time'] * 3600));
$sql = "SELECT id FROM reserve WHERE reserve_time < '{$delete_time}' AND deposit=0 AND total_cost=0 AND approve=0";
$query = mysql_query($sql) or die($sql);
$delete_ids = array();
while ($row = mysql_fetch_assoc($query))
{
$delete_ids[] = $row['id'];
}
if ($delete_ids)
{
$sql1 = "DELETE FROM reserve WHERE id IN(".join(', ',$delete_ids).")";
$sql2 = "DELETE FROM room_reserve WHERE reserve_id IN(".join(', ',$delete_ids).")";
$sql3 = "DELETE FROM food_reserve WHERE reserve_id IN(".join(', ',$delete_ids).")";
mysql_query($sql1) or die($sql1);
mysql_query($sql2) or die($sql2);
mysql_query($sql3) or die($sql3);
}
?>
<!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>ระบบจองห้องประชุม - หน้าแรก</title>
<link rel="stylesheet" type="text/css" href="media/css/default.css"/>
<script type="text/javascript" src="media/js/jquery-1.4.2.min.js"></script>
<style type="text/css">
<!--
.style2 {font-size: 24px; font-weight: bold; }
-->
</style>
</head>
<body>
<?php header_page(); ?>
<table width="950" bgcolor="#FFFFFF" border="0" align="center" cellpadding="0" cellspacing="0" class="body-border" style="padding: 10px 0 10px 0;">
<tr>
<td width="225" align="center" valign="top" class="right_dash">
<?php login_box(); ?>
<br />
</td>
<td width="707" valign="top" bgcolor="#FFFFCC">
<div align="left">
<?php
$room1 = "select * from room where id = '".$_GET["id"]."'";
$room_sql1 = mysql_query($room1);
$room_sql2 = mysql_fetch_array($room_sql1);
?>
</div>
<table width="15%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#00FF00">
<tr>
<td><div align="center"><?php echo $room_sql2["name"];?></div></td>
</tr>
<tr>
<td><div align="center"><img src="room_picture/<?php echo $room_sql2['picture'];?>" style="float:left; margin: 0 4px 4px 0" /></div></td>
</tr>
</table>
<br />
<?php
$user_sql = "select * from used where room_id ='".$_GET["id"]."'";
$mysql_user = mysql_query($mysql_user);
if(mysql_num_rows($mysql_user) > 0){
$mysql_test = mysql_fetch_array($mysql_user);
?>
<div align="center">
<table width="56%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
<tr>
<td bgcolor="#CCFF99"><div align="center" class="style2">วันที่จอง</div></td>
<td bgcolor="#CCFF99"><div align="center" class="style2">ผู้จอง</div></td>
</tr>
<tr>
<td><div align="center"><?php echo $mysql_test["used_day"];?></div></td>
<td><div align="center"><?php echo $mysql_test["name"];?></div></td>
</tr>
</table>
</div>
<?
}
?>
</div>
<br />
<div align="center"></div></td>
</tr>
</table>
<?php
mysql_close();
?>
<?php footer_page(); ?>
</body>
</html>
Date :
2011-11-07 11:17:15
By :
ikikkok
echo $room1 = "select * from room where id = '".$_GET["id"]."'"; อันนี้ออกมาดูครับ
Date :
2011-11-07 11:42:45
By :
ikikkok
Load balance : Server 05