markman
06-15-2005, 07:46 AM
Hey all.
I am having some trouble with a mysql_fetch_array statement in a script (bellow) that should make news from a message board appear on the screen.
<?php
include("nav.php");
?>
<td width="610" valign="top" border="1">
<table width="610" cellpading="0" cellspacing="0" align="left" border="0">
<tr>
<td width='610' height='9' bgcolor='#000000' valign='top'></td>
</tr>
<tr>
<td width='610' height='13' background='images/index_06.gif' valign='top'></td>
</tr>
<tr>
<td>
<table width='610' border='0' rowspan='0' background='images/index_08.gif' >
<?php
include("connections/forum.php");
$get = mysql_query("SELECT * FROM `threads` WHERE `type` = 'announcement' ORDER BY id");
while ($array = mysql_fetch_array($get)) {
$poster = $array['poster'];
$get2 = mysql_query("SELECT * FROM users WHERE username='$poster'");
while ($array2 = mysql_fetch_array($get2)) {
echo "<tr>
<td width='15%'><b><u>$array[poster]</u></b></a></td>
<td width='84%' align='right'>$array[posttime]</td>
</tr>
<tr>
<td align='center' valign='middle'>
<img src='images/admin.jpg' alt='' border='2' width='80' height='80' />
</td>
<td width='84%' valign='top'><b><u>$array[title]</u></b><br /><br /><br /><br />\n
$array[message]<br /><br />
________________________________________________________________
</td>
</tr>
";
}
}
?>
</table>
</td>
</tr>
<tr>
<td width='610' height='13' background='images/index_06.gif' valign='top' border='1'></td>
</tr>
</td>
</table>
</td>
<td width="10" height="542" bgcolor="#000000" valign="top" border="1"></td>
<td width="127" height="2" colspan="0" valign="top" background="images/index_04.gif" rowspan="16" align="top">
<table cellpading="0" cellspacing="0" align="top" border="1">
<tr>
<td valign="top" rowspan="2" border="1">
<?php
if (!$_SESSION['userid']) {
?>
<center><b>Log in</b></center>
<form method="POST" action="login2.php">
Username :<br />
<input type="text" name="username" title="username" id="username" size="15" /><br />
Password :<br />
<input type="text" name="password" title="password" id="password" size="15" />
<input type="submit" value="Log in" /><input type="reset" value="reset" />
</form>
<?php
} else {
?>
Welcome back : <br /><b><?php echo $_SESSION[username]; ?></b><br /><br />
<img src="<?php echo $_SESSION[avatar]; ?>" alt="" border="2" /><br /><br />
<a href="modifyprofile.php?id=<?php echo $_SESSION[userid]; ?>">
Modify your profile</a>
<?php
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Line 21 is where the error is, it says it isn't a valid mySql ressource :eek:
Line 21 is :
$get2 = mysql_query("SELECT * FROM users WHERE username='$poster'");
I am having some trouble with a mysql_fetch_array statement in a script (bellow) that should make news from a message board appear on the screen.
<?php
include("nav.php");
?>
<td width="610" valign="top" border="1">
<table width="610" cellpading="0" cellspacing="0" align="left" border="0">
<tr>
<td width='610' height='9' bgcolor='#000000' valign='top'></td>
</tr>
<tr>
<td width='610' height='13' background='images/index_06.gif' valign='top'></td>
</tr>
<tr>
<td>
<table width='610' border='0' rowspan='0' background='images/index_08.gif' >
<?php
include("connections/forum.php");
$get = mysql_query("SELECT * FROM `threads` WHERE `type` = 'announcement' ORDER BY id");
while ($array = mysql_fetch_array($get)) {
$poster = $array['poster'];
$get2 = mysql_query("SELECT * FROM users WHERE username='$poster'");
while ($array2 = mysql_fetch_array($get2)) {
echo "<tr>
<td width='15%'><b><u>$array[poster]</u></b></a></td>
<td width='84%' align='right'>$array[posttime]</td>
</tr>
<tr>
<td align='center' valign='middle'>
<img src='images/admin.jpg' alt='' border='2' width='80' height='80' />
</td>
<td width='84%' valign='top'><b><u>$array[title]</u></b><br /><br /><br /><br />\n
$array[message]<br /><br />
________________________________________________________________
</td>
</tr>
";
}
}
?>
</table>
</td>
</tr>
<tr>
<td width='610' height='13' background='images/index_06.gif' valign='top' border='1'></td>
</tr>
</td>
</table>
</td>
<td width="10" height="542" bgcolor="#000000" valign="top" border="1"></td>
<td width="127" height="2" colspan="0" valign="top" background="images/index_04.gif" rowspan="16" align="top">
<table cellpading="0" cellspacing="0" align="top" border="1">
<tr>
<td valign="top" rowspan="2" border="1">
<?php
if (!$_SESSION['userid']) {
?>
<center><b>Log in</b></center>
<form method="POST" action="login2.php">
Username :<br />
<input type="text" name="username" title="username" id="username" size="15" /><br />
Password :<br />
<input type="text" name="password" title="password" id="password" size="15" />
<input type="submit" value="Log in" /><input type="reset" value="reset" />
</form>
<?php
} else {
?>
Welcome back : <br /><b><?php echo $_SESSION[username]; ?></b><br /><br />
<img src="<?php echo $_SESSION[avatar]; ?>" alt="" border="2" /><br /><br />
<a href="modifyprofile.php?id=<?php echo $_SESSION[userid]; ?>">
Modify your profile</a>
<?php
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Line 21 is where the error is, it says it isn't a valid mySql ressource :eek:
Line 21 is :
$get2 = mysql_query("SELECT * FROM users WHERE username='$poster'");