Hello,
I’ve got a little problem with the php guestbook i’ve been working on. I use the guestbook with a database in PHPmyadmin. I’ve got the files to work mostly correct, it shows the guestbook (viewguestbook.php) when entering that section, lets you add a new entry (addguestbook.php). After making a new entry in the guestbook when you’d click submit it shows a blank page with ‘gelukt!’ (succesful!) and takes you to the guestbook where the new entry is added. One small problem, the entry is entirely blank but for the time/date. It does show the fields for name, email and message but there’s nothing next to that.
I’ve shown the PHP code below
I’ve set up the database properly i thought, but my guess is i went wrong at that part…
PHP:
[php]
// Connect to server and select database.
mysql_connect("$host", “$username”, “$password”)or die(“cannot connect server “);
mysql_select_db(”$db_name”)or die(“cannot select DB”);
$datetime=date(“y-m-d h:i:s”); //date time
$sql=“INSERT INTO $tbl_name(name, email, comment, datetime)VALUES(’$name’, ‘$email’, ‘$comment’, ‘$datetime’)”;
$result=mysql_query($sql);
//check if query successful
if($result){
echo “Gelukt!”;
echo “
”;
echo “naar het gastenboek.”; // link to view guestbook page
}
else {
echo “Oeps! er ging iets fout…”;
}
mysql_close();
?>
[php]
<? include 'head.php';?>Gastenboek | Laat een bericht achter! |
<?php $host="db.devuilnisprinses.nl"; // Host name $username="md223309db172500"; // Mysql username $password="Nl3YT1lz"; // Mysql password $db_name="md223309db172500"; // Database name $tbl_name="guestbook"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?>
|
<? } mysql_close(); //close database ?>
[php]
<? include 'head.php';?> <? include 'footer.php';?> [/php]