Probleem bij forumscript
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:
De code van het script:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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>
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?
dankje.
Gewijzigd op 01/09/2011 20:32:22 door Kees van Kempen
nog iets, in houw geval kun je beter mysql_fetch_assoc() gebruiken ipv mysql_fetch_array()
oke, waarom xd?