Jump to content

Archived

This topic is now archived and is closed to further replies.

creativkook

Fetch Arrays

Recommended Posts

I keep getting this error that my fetch arrays are not a valid resource for the two located near the bottom of my code, the ones hilighted. Can anyone see what I'm doing wrong? I'm trying to pull out entries for a simple forum, using three database tables that tie together. Thanks!

<?php

require("dbheader.php");

$topic = mysql_fetch_array(mysql_query("SELECT topic FROM topics WHERE topicid = $_GET[topicid]"));
echo(mysql_error());

$title = $topic['topic'];

$entries = mysql_query("SELECT *, UNIX_TIMESTAMP(eventTime) AS utime FROM entry WHERE topicid = $_GET[topicid]");

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo($title); ?></title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<?php

[b]$entry = mysql_fetch_array($entries);[/b]
$userid = $entry['userid'];
[b]$user = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE userid = $userid"));[/b]
$edate = date("l, F jS", $entry['utime']);
$etime = date("g:i a", $entry['utime']);

while($entry)
{
echo("<div class='display'");

echo("<table cellpadding='3' cellspacing='3'>");
echo("<tr>");
echo("<td>");
echo("<p>$user[username]</p>");
echo("<p>$edate at $etime</p>");
echo("</td>");
echo("<td>");
echo("<p>$entry[entry]</p>");
echo("</td>");
echo("</tr>");

echo("</div>");
}

?>

</body>
</html>

Share this post


Link to post
Share on other sites
You should break up your queries to narrow down errors. When you get that error usually it is a problem with your query. try enclosing the value in your where clause like below.

[code]$sql = "SELECT topic FROM topics WHERE topicid = ".$_GET[topicid]."";
$result = mysql_query($sql) or die (mysql_error());[/code]

Ray

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.