Hallo iedereen,
Ik ben bezig met een eigen forum en stuit nu op een error in de mysql_fetch_array:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\wamp\www\njosaus4\forum.php on line 56
De regel met de error:
while($topics = mysql_fetch_array($query_posts)) { ?>

De code van het script:

<?php
require('./ip.php');
session_start();
//error_reporting(0);
?>
<!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>
<?php require('./meta.html'); ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Forum - Josaus.com</title>
<link href="./styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="menu">
  <?php require('./menu.html'); ?>
</div>
<div id="sidebar">
  <?php
  if($_GET['reg'] != 1 || $_SESSION['login']) {
      include('./login.php');
  }
  ?>
</div>
<div id="content">
  <h1>Forum</h1>
  <div id="forum">
    <div class="section">
    <h3>Algemeen</h3>
    </div>
    <div class="section">
    <h3>Overig</h3>
    </div>
  </div>
<?php
	$sql_sections = "
	  SELECT id, name
	  FROM forum_sections
	";
	$query_sections = mysql_query($sql_sections);
	
	
	while($sections = mysql_fetch_array($query_sections)) {
		$sql_posts = "
		  SELECT id, userid, topic_start, section, topic, subject
		  FROM posts
		  WHERE topic_start = 1
		  AND section = " . mysql_real_escape_string($sections['id']) . "
		";
		$query_posts = mysql_query($sql_posts);
		?>
      <div class="section">
        <h3><?php echo $sections['name']; ?></h3>
        <?php
		while($topics = mysql_fetch_array($query_posts)) { ?>
			<span class='topic'><?php echo $topics['subject']; ?></span><br />
            <?php
		}
		?>
      </div>
    <?php	
	}
  ?>
</div>
</body>
</html>

Ik hoop dat het een klein foutje is xD

Alvast bedankt, Kees.
echo mysql_error() onder de query?
gevonden, typfout @ tabelnaam.
dankje.
nog iets, in houw geval kun je beter mysql_fetch_assoc() gebruiken ipv mysql_fetch_array()
zie deze tutorial

Reageren