With the below script im getting the pretty well-known error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Programmer\xampp\htdocs\webpages\Samfprog\guestbook.php on line 41
However, the error is not the biggest of my problems, since im not really in the need of that part of the site, what i need to do is to figure out why this script neglects to post the info i type in the boxes on the site that this script creates.
<html>
<head>
</head>
<body>
<?php
$db = mysql_connect("localhost", "secret", "secret"); <- password and user correct - would however like to keep them secret ;-)
mysql_select_db("gbog, $db");
if ($_POST['skriv']){
$email = $_POST["navn"];
$password = $_POST["email"];
$email = $_POST["besked"];
if(get_magic_quotes_gpc()){
$email = addslashes($email);
$password = addslashes($password);
}
$dato_array = getdate();
$dato = $dato_array["mday"]."/".
$dato_array["mon"]."-".
$dato_array["year"];
mysql_query("INSERT INTO bog (navn, email, dato, besked) VALUES ('$navn', '$email', '$dato', '$besked')");
}
?>
<center>
<form method="post" action="<?php echo $PHP_SELF; ?>">
<input type="hidden" name="skriv" value="1">
navn: <input type="text" name="navn"<br>
email: <input type="text" name="email"<br>
<textarea name="besked" cols="30" rows="5"></textarea><br>
<INPUT TYPE=submit VALUE="send">
</form>
<br><br>
<table>
<?php
$foresp = mysql_query("SELECT navn, email, dato FROM bog ORDER BY nr DESC");
While($data = mysql_fetch_array($foresp)){
echo "<tr><td valign=\"top\">";
echo "fra: <a href=\"mailto:";
echo $data["email"];
echo "\">";
echo $data["navn"];
echo "</a>";
echo "<br>";
echo "</td><td valign=\"top\">";
echo nl2br($data["besked"]);
echo "</td> </tr>";
}
?>
</table>
</center>
</body>
</html>