Skip navigation links

MySQL Forums :: PHP :: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7


Advanced Search

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7
Posted by: Scott Mosman ()
Date: May 01, 2011 01:03PM

I’ve spent countless hours trying to fix this error. Can someone please help? I believe that 99% my codes are correct, in the right location and all my database connections are good.

Here is my script for index.php

<?php
// Connect to database
include_once "scripts/connect_to_mysql.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");

(line 7) while($row = mysql_fetch_array($sql)){

$MemberDisplayList = '<table border="0" align="center" cellpadding="6">
<tr> ';

$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
}

$MemberDisplayList .= '<td><div style=" height:80px; overflow:hidden;"><a href="http://www.mywebsite.com/res.php?id=' . $id . '">' . $user_pic . '</a></div><a href="http://www.mywebsite.com/res.php?id=' . $id . '"><div align="center" style=" width:80px; overflow:hidden;">' . $firstname . '</div></a></td>';

} // close while loop

$MemberDisplayList .= ' </tr>
</table> ';
?>

<?php
$sql_annos = mysql_query("SELECT id, mem_id, the_anno, anno_date FROM announcing ORDER BY anno_date DESC LIMIT 20");

while($row = mysql_fetch_array($sql_annos)){

$annoid = $row["id"];
$uid = $row["mem_id"];
$the_anno = $row["the_anno"];
$anno_date = $row["anno_date"];
$anno_date = strftime("%b %d, %Y %I:%M:%S %p", strtotime($anno_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)) {
$announcer_pic = "<img src=\"$ucheck_pic\" width=\"40px\" border=\"0\" />"; // forces picture to be 100px wide and no more
} else {
$announcer_pic = "<img src=\"$udefault_pic\" width=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more
}

$announcerDisplayList .= '
<table width="100%" align="center" cellpadding="4" bgcolor="#A6D2FF">
<tr>
<td width="10%" bgcolor="#FFFFFF"><a href="http://www.mywebsite.com/res.php?id=' . $uid . '">' . $announcer_pic . '</a><br />
</td>
<td width="90%" bgcolor="#D9ECFF"><a href="http://www.mywebsite.com/res.php?id=' . $uid . '">' . $ufirstname . ' ' . $ulastname . '</a> &bull; <span style="font-size:10px; font-weight:bold; color:#A6A6A6;">' . $anno_date . '</span><br />
' . $the_anno . '</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="misc stuff" />
<meta name="Keywords" content="misc, stuff" />
<title>My Web Site</title>
<link href="style/main.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="http://www.mywebsite.com/favicon.ico"; type="image/x-icon" />
<link rel="shortcut icon" href="http://www.mywebsite.com/favicon.ico"; type="image/x-icon" />
<style type="text/css">
<!--
.giantArrow {
font-size: 36px;
}
-->
</style>
</head>

<body>
<?php include_once "header_template.php"; ?>
<table width="965" align="center">
<tr>
<td width="872" valign="top"><p align="center"><br />
<span class="boldtext"><strong>Newest - Members</strong></span></p>
<p align="center"></p>
<table width="92%" height="407" align="center" cellpadding="6">
<tr>
<td width="100%"><div align="left">
<p><br />
<span class="lgtext">Members Make Announcements, post what&rsquo;s on your mind for all to hear!</span></p>
</div></td>
</tr>
<td bgcolor="#FFFFFF">
<div align="left"><strong class="black">Make Your Announcement Here&hellip;</strong></div></td>
</tr>
<tr>

<td valign="top">

<div style="width:850px; background-color:#EFEFEF; border:#999 thin solid;"><?php print "$MemberDisplayList"; ?></div>

<br />

<div style="width:850px; height:240px; border:#999 thin solid; overflow:auto;"><?php print "$announcerDisplayList"; ?></div>

</td>
</tr>
</table>
<br />
<br /></td>
<td width="70" valign="top"><?php include_once "right_AD_template.php"; ?></td>

<td width="7"></td>
</tr>

</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>

Options: ReplyQuote


Subject Written By Posted
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7 Scott Mosman 05/01/2011 01:03PM
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7 Barry Galbraith 05/01/2011 04:49PM
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7 Scott Mosman 05/02/2011 12:40AM
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7 Barry Galbraith 05/02/2011 03:01AM
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mywebsite/public_html/index.php on line 7 Scott Mosman 05/06/2011 11:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.