Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result reso
daar ben ik weer met een vraag over een error. als het volgende script run krijg ik de volgende error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\shoutbox.php on line 15
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
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
<?php
include "dbconnect.php";
if ($_GET['actie'] == 'add') {
$datum = date("y-m-d : H:i:s",time());
$naam = $_POST['name'];;
$textadd = $_POST['textcomment'];
if ($naam=="") { $naam="Anoniempje";}
$add = "INSERT INTO shout (text, user, datum) VALUES ('$textadd', '$naam', '$datum')";
mysql_query($add) or die(mysql_error());
}
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr><th colspan=\"2\" align=\"left\">Shoutbox</th></tr>";
$sql = "SELECT * FROM shout ORDER BY datum DESC LIMIT 3";
$shout = mysql_query($sql) or die(mysql_error());
while ($rij = mysql_fetch_assoc($shout)) {
$count++;
if ($count%2 > 0) { $color="#d2d2d2";}else{$color="#737373"; }
$shout = $rij[text];
$naamshout = $rij[user];
$datum = $rij[datum];
echo "<tr bgcolor='$color'><td width=\"55\">$naamshout $datum</td><td width=\"185\">$shout</td></tr>";
}
echo "</table><br />";
echo "<form action=\"".$_SERVER['PHP_SELF']."?actie=add\" method=\"post\">";
echo "<input type=\"text\" name=\"name\" size=\"25\"><br />";
echo "<textarea name=\"textcomment\" row=\"25\">";
echo "</textarea>";
echo "<input type=\"submit\" value=\"Post comment\">";
echo "</form></div>";
?>
include "dbconnect.php";
if ($_GET['actie'] == 'add') {
$datum = date("y-m-d : H:i:s",time());
$naam = $_POST['name'];;
$textadd = $_POST['textcomment'];
if ($naam=="") { $naam="Anoniempje";}
$add = "INSERT INTO shout (text, user, datum) VALUES ('$textadd', '$naam', '$datum')";
mysql_query($add) or die(mysql_error());
}
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr><th colspan=\"2\" align=\"left\">Shoutbox</th></tr>";
$sql = "SELECT * FROM shout ORDER BY datum DESC LIMIT 3";
$shout = mysql_query($sql) or die(mysql_error());
while ($rij = mysql_fetch_assoc($shout)) {
$count++;
if ($count%2 > 0) { $color="#d2d2d2";}else{$color="#737373"; }
$shout = $rij[text];
$naamshout = $rij[user];
$datum = $rij[datum];
echo "<tr bgcolor='$color'><td width=\"55\">$naamshout $datum</td><td width=\"185\">$shout</td></tr>";
}
echo "</table><br />";
echo "<form action=\"".$_SERVER['PHP_SELF']."?actie=add\" method=\"post\">";
echo "<input type=\"text\" name=\"name\" size=\"25\"><br />";
echo "<textarea name=\"textcomment\" row=\"25\">";
echo "</textarea>";
echo "<input type=\"submit\" value=\"Post comment\">";
echo "</form></div>";
?>
Hoe krijg ik deze melding weg?
http://www.google.nl/search?hl=nl&q=Warning%3A+mysql_fetch_assoc%28%29%3A+supplied+argument+is+not+a+valid+MySQL+result+resource+in&btnG=Google+zoeken&meta=
1ste 3 pagin's mensen die dat probleem op hun site hebben + relevante oplossingen
1ste 3 pagin's mensen die dat probleem op hun site hebben + relevante oplossingen
alleen blijft de melding hetzelfde:(
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
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
<?php
include "dbconnect.php";
if ($_GET['actie'] == 'add') {
$datum = date("y-m-d : H:i:s",time());
$naam = $_POST['name'];;
$textadd = $_POST['textcomment'];
if ($naam=="") { $naam="Anoniempje";}
$add = "INSERT INTO shout (text, user, datum) VALUES ('$textadd', '$naam', '$datum')";
mysql_query($add) or die(mysql_error());
}
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr><th colspan=\"2\" align=\"left\">Shoutbox</th></tr>";
$sql = "SELECT * FROM shout ORDER BY datum DESC LIMIT 3";
$shout = mysql_query($sql) or die(mysql_error());
if ($shout && mysql_num_rows($shout) >= 1) {
while ($rij = mysql_fetch_assoc($shout)) {
$count++;
if ($count%2 > 0) { $color="#d2d2d2";}else{$color="#737373"; }
$shout = $rij[text];
$naamshout = $rij[user];
$datum = $rij[datum];
echo "<tr bgcolor='$color'><td width=\"55\">$naamshout $datum</td><td width=\"185\">$shout</td></tr>";
}
} else {
echo "Geen data gevonden";
}
echo "</table><br />";
echo "<form action=\"".$_SERVER['PHP_SELF']."?actie=add\" method=\"post\">";
echo "<input type=\"text\" name=\"name\" size=\"25\"><br />";
echo "<textarea name=\"textcomment\" row=\"25\">";
echo "</textarea>";
echo "<input type=\"submit\" value=\"Post comment\">";
echo "</form></div>";
?>
include "dbconnect.php";
if ($_GET['actie'] == 'add') {
$datum = date("y-m-d : H:i:s",time());
$naam = $_POST['name'];;
$textadd = $_POST['textcomment'];
if ($naam=="") { $naam="Anoniempje";}
$add = "INSERT INTO shout (text, user, datum) VALUES ('$textadd', '$naam', '$datum')";
mysql_query($add) or die(mysql_error());
}
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr><th colspan=\"2\" align=\"left\">Shoutbox</th></tr>";
$sql = "SELECT * FROM shout ORDER BY datum DESC LIMIT 3";
$shout = mysql_query($sql) or die(mysql_error());
if ($shout && mysql_num_rows($shout) >= 1) {
while ($rij = mysql_fetch_assoc($shout)) {
$count++;
if ($count%2 > 0) { $color="#d2d2d2";}else{$color="#737373"; }
$shout = $rij[text];
$naamshout = $rij[user];
$datum = $rij[datum];
echo "<tr bgcolor='$color'><td width=\"55\">$naamshout $datum</td><td width=\"185\">$shout</td></tr>";
}
} else {
echo "Geen data gevonden";
}
echo "</table><br />";
echo "<form action=\"".$_SERVER['PHP_SELF']."?actie=add\" method=\"post\">";
echo "<input type=\"text\" name=\"name\" size=\"25\"><br />";
echo "<textarea name=\"textcomment\" row=\"25\">";
echo "</textarea>";
echo "<input type=\"submit\" value=\"Post comment\">";
echo "</form></div>";
?>
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\shoutbox.php on line 16
Shoutbox
Test 2008-08-07 10:43:57 shout
Gewijzigd op 01/01/1970 01:00:00 door arend b
Jacco schreef op 07.08.2008 11:08:
http://www.google.nl/search?hl=nl&q=Warning%3A+mysql_fetch_assoc%28%29%3A+supplied+argument+is+not+a+valid+MySQL+result+resource+in&btnG=Google+zoeken&meta=
1ste 3 pagin's mensen die dat probleem op hun site hebben + relevante oplossingen
1ste 3 pagin's mensen die dat probleem op hun site hebben + relevante oplossingen
Heb ik al gezocht maar ik werd er niet veel wijzer van want bij mij geeft die wel een output maar ook een foutmelding