Ik heb een programma geschreven die voor ieder filmpje een aparte pagina opent waarin alle ingevoerde commentaar uit het database worden gehaald.
in de video-pagina roep ik 2 functie's op:
Functie aanroep 1:
[code=php]
<div id="video">
<?php $topicfull = view_full_topic($myposts); ?>
</div>
[/code=php]
Functie view_full_topic();
[code=php]
// view topic full
function view_full_topic($myposts){
global $result;
if ($myposts) {
do {
$post_id = $myposts["post_id"];
$title = $myposts["title"];
$post = format($myposts["post"]);
$dateattime = $myposts["dateattime"];
$topicfull = $post_id . $title . $post . $dateattime; // wordt doorgestuurd naar blogpost.php
echo "<br /><img src=\"img/btn2.png\" alt=\"appel\" longdesc=\"www.overdatum.nl\" />\n";
echo "<h4>$title</h4>\n";
echo "<p>Getypt op $dateattime</p><br />";
echo "$post";
} while ($myposts = mysql_fetch_array($result));
return $result;
} else {
echo "<p>There is no post matching a post_id of $post_id.</p>";
}
}
[/code=php]
Functie aanroep 2:
[php=code]
<div id="commentaar">
<?php view_blaat(); ?>
</div>
[/php=code]
Functie view_blaat();
[code=php]
<div id="commentaar">
function view_blaat(){
global $myposts;
global $result3;
if ($myposts) {
$sql = "SELECT comment_id, name, website, comment FROM comments
WHERE post_id = $post_id";
$result3 = mysql_query($sql);
//echo "sql: $sql";
$mycomments = mysql_fetch_array($result3);
// echo "Resultaat ".mysql_num_rows($sql)."rijen";
}
if ($mycomments) {
echo "<dl>";
do {
$comment_id = $mycomments["comment_id"];
$name = $mycomments["name"];
$website = $mycomments["website"];
$comment = format($mycomments["comment"]);
// $commentaar = $comment_id . $name . $website . $comment;
if ($website != "") {
echo "<p><a href='{$website}'>$name</a> blaat:";
} else {
echo '<p><b>' . $name . ' blaat:</b>';
}
echo $comment . '</p>';
} while ($mycomments = mysql_fetch_array($result3));
echo "</dl>";
return $myposts;
} else {
echo "<p>Niemand heeft nog geblaat</p><br /><br />";
}
}
[/code=php]
Deze melding krijg ik:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in functions.php on line 108
Als ik
[code=php]
global $myposts;
[/code=php]
weghaal binnen de functie view_blaat(); krijg ik geen database resultaat op de webpagina.
Welke mogenlijkheden heb ik nog tot mijn bechikking om mijn code uitgebreider te testen, zodat ik weet waar ik een fout heb gemaakt?
in de video-pagina roep ik 2 functie's op:
Functie aanroep 1:
[code=php]
<div id="video">
<?php $topicfull = view_full_topic($myposts); ?>
</div>
[/code=php]
Functie view_full_topic();
[code=php]
// view topic full
function view_full_topic($myposts){
global $result;
if ($myposts) {
do {
$post_id = $myposts["post_id"];
$title = $myposts["title"];
$post = format($myposts["post"]);
$dateattime = $myposts["dateattime"];
$topicfull = $post_id . $title . $post . $dateattime; // wordt doorgestuurd naar blogpost.php
echo "<br /><img src=\"img/btn2.png\" alt=\"appel\" longdesc=\"www.overdatum.nl\" />\n";
echo "<h4>$title</h4>\n";
echo "<p>Getypt op $dateattime</p><br />";
echo "$post";
} while ($myposts = mysql_fetch_array($result));
return $result;
} else {
echo "<p>There is no post matching a post_id of $post_id.</p>";
}
}
[/code=php]
Functie aanroep 2:
[php=code]
<div id="commentaar">
<?php view_blaat(); ?>
</div>
[/php=code]
Functie view_blaat();
[code=php]
<div id="commentaar">
function view_blaat(){
global $myposts;
global $result3;
if ($myposts) {
$sql = "SELECT comment_id, name, website, comment FROM comments
WHERE post_id = $post_id";
$result3 = mysql_query($sql);
//echo "sql: $sql";
$mycomments = mysql_fetch_array($result3);
// echo "Resultaat ".mysql_num_rows($sql)."rijen";
}
if ($mycomments) {
echo "<dl>";
do {
$comment_id = $mycomments["comment_id"];
$name = $mycomments["name"];
$website = $mycomments["website"];
$comment = format($mycomments["comment"]);
// $commentaar = $comment_id . $name . $website . $comment;
if ($website != "") {
echo "<p><a href='{$website}'>$name</a> blaat:";
} else {
echo '<p><b>' . $name . ' blaat:</b>';
}
echo $comment . '</p>';
} while ($mycomments = mysql_fetch_array($result3));
echo "</dl>";
return $myposts;
} else {
echo "<p>Niemand heeft nog geblaat</p><br /><br />";
}
}
[/code=php]
Deze melding krijg ik:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in functions.php on line 108
Als ik
[code=php]
global $myposts;
[/code=php]
weghaal binnen de functie view_blaat(); krijg ik geen database resultaat op de webpagina.
Welke mogenlijkheden heb ik nog tot mijn bechikking om mijn code uitgebreider te testen, zodat ik weet waar ik een fout heb gemaakt?
[ Voor 3% gewijzigd door Zakkenwasser op 05-12-2008 22:44 ]
PSP 1000 @ 6.60 Pro C2 [+256GB]
PSVita @ Henkaku Enso [+256GB]
3DS @ Luma (B9S) [+160GB]
Nintendo Switch 3.0.1 [+256GB]