ช่วยดูหน่อยคับ mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Code (PHP)
<?php
// Connect to database
include_once "scripts/connect.php";
// Gather all the members for temporary display
$sql = mysql_query("SELECT id, firstname, lastname FROM myMembers WHERE email_activated='1' ORDER BY id DESC LIMIT 6");
$MemberDisplayList = '<table border="0" align="center" cellpadding="6">
<tr> ';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$firstname = $row["firstname"];
$lastname = $row["lastname"];
$firstname = substr($firstname, 0, 10);
/////// Mechanism to Display Pic. See if they have uploaded a pic or not //////////////////////////
$check_pic = "members/$id/image01.jpg";
$default_pic = "members/0/image01.jpg";
if (file_exists($check_pic)) {
$user_pic = "<img src=\"$check_pic\" width=\"80px\" border=\"0\" />"; // width attribute forces picture to be 80px wide and no more
} else {
$user_pic = "<img src=\"$default_pic\" width=\"80px\" border=\"0\" />"; // width attribute forces default picture to be 80px wide and no more
}
$MemberDisp=layList. '<td><div style=" height:80px; overflow:hidden;"><a href="http://www.webintersect.com/profile.php?id=' . $id . '">' . $user_pic . '</a></div><a href="http://www.webintersect.com/profile.php?id=' . $id . '"><div align="center" style=" width:80px; overflow:hidden;">' . $firstname . '</div></a></td>';
} // close while loop
$MemberDisplayList .= ' </tr>
</table> ';
?>
<?php
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing ORDER BY blab_date DESC LIMIT 20");
while($row = mysql_fetch_array($sql_blabs)){
$blabid = $row["id"];
$uid = $row["mem_id"];
$the_blab = $row["the_blab"];
$blab_date = $row["blab_date"];
$blab_date = strftime("%b %d, %Y, %Y %I:%M:%S %p", strtotime($blab_date));
// Inner sql query
$sql_mem_data = mysql_query("SELECT id, firstname, lastname FROM myMembers WHERE id='$uid' LIMIT 1");
while($row = mysql_fetch_array($sql_mem_data)){
$uid = $row["id"];
$ufirstname = $row["firstname"];
$ulastname = $row["lastname"];
$ufirstname = substr($ufirstname, 0, 10);
/////// Mechanism to Display Pic. See if they have uploaded a pic or not //////////////////////////
$ucheck_pic = "members/$uid/image01.jpg";
$udefault_pic = "members/0/image01.jpg";
if (file_exists($ucheck_pic)) {
$blabber_pic = "<img src=\"$ucheck_pic\" width=\"40px\" border=\"0\" />"; // forces picture to be 100px wide and no more
} else {
$blabber_pic = "<img src=\"$udefault_pic\" width=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more
}
$blabberDisplayList .= '
<table width="90%" align="center" cellpadding="4" bgcolor="#A6D2FF">
<tr>
<td width="7%" bgcolor="#FFFFFF"><a href="http://www.webintersect.com/profile.php?id=' . $uid . '">' . $blabber_pic . '</a><br />
</td>
<td width="93%" bgcolor="#D9ECFF"><a href="http://www.webintersect.com/profile.php?id=' . $uid . '">' . $ufirstname . ' ' . $ulastname . '</a> • <span style="font-size:10px; font-weight:bold; color:#A6A6A6;">' . $blab_date . '</span><br />
' . $the_blab . '</td>
</tr>
</table>';
}
}
?>
<!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=iso-8859-1" />
<meta name="Description" content="Page Description goes here" />
<meta name="Keywords" content="Page Keywords go here" />
<meta name="rating" content="General" />
<meta name="revisit-after" content="7 days" />
<meta name="ROBOTS" content="All" />
<title>your new cool site</title>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="http://www.yournewcoolsite.com/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://www.yournewcoolsite.com/favicon.ico" type="image/x-icon" />
</head>
<body>
<?php include_once "header_template.php"; ?>
<table width="950" align="center">
<tr>
<td width="758" valign="top"><p align="center"><br />
NEWEST MEMBERS<br />
<?php print "$MemberDisplayList"; ?></p>
<table width="92%" align="center" cellpadding="6">
<tr>
<td width="100%"><strong>MEMBER BLABS - These are the smartest people on Earth blabbing about stuff. Their mind power cannot be matched.</strong></td>
</tr>
</table>
<!--
<table width="90%" align="center" cellpadding="4" bgcolor="#A6D2FF">
<tr>
<td width="10%" bgcolor="#FFFFFF"><a href="http://www.webintersect.com/profile.php?id=' . $uid . '">' . $blabber_pic . '</a><br />
</td>
<td width="90%" bgcolor="#D9ECFF"><a href="http://www.webintersect.com/profile.php?id=' . $uid . '">' . $ufirstname . ' ' . $ulastname . '</a> • <span style="font-size:10px;">' . $blab_date . '</span><br />
' . $the_blab . '</td>
</tr>
</table> -->
<div style="width:100%; height:240px; overflow:auto; overflow-x:hidden;">
<?php print "$blabberDisplayList"; ?>
</div>
<br />
<br /></td>
<td width="180" valign="top"><?php include_once "right_AD_template.php"; ?></td>
</tr>
</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>
Tag : PHP, MySQL
Date :
2012-06-03 01:14:46
By :
nukedonut1
View :
985
Reply :
2
มีปัญหาที่คำสั่ง select น่ะ ลองเช็คคำสั่งใหม่ดูนะ หรือเอาคำสั่งไปรันใน phpmyadmin ดูว่าทำงานได้ไหม
Date :
2012-06-03 07:41:39
By :
บังเอิญผ่านมาเห็น
Code (PHP)
$sql = " SELECT id, firstname, lastname FROM myMembers WHERE email_activated='1' ORDER BY id DESC LIMIT 6 ";
$result = mysql_query($sql) or die(mysql_error());
ลองใส่ mysql_error() ดูว่า error อะไรครับ
Date :
2012-06-03 07:42:01
By :
mr.win
Load balance : Server 04