Jump to content

Fetch Arrays


creativkook

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>
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.