Hello. I've just started learning PHP recently, and following a tutorial, I decided to try out making a guestbook. I can get the script to enter the information into the database, but I'm having trouble pulling it out so it views on a webpage. All other text displays but variables do not. There are no errors appearing. Here's the View.php page which is supposed to display the information:
view.php
<?
include("dbconnect.php");
echo("
<h2>Viewing my guestbook...</h2>
");
$result = mysql_query("select * from guestbook") or
die (mysql_error());
while ($row = mysql_fetch_array($result))
{
echo "<b>Name:</b>";
echo $row["name"];
echo "<br>\n";
echo "<b>Location:</b>";
echo $row["location"];
echo "<br>\n";
echo "<b>Email:</b>";
echo $row["email"];
echo "<br>\n";
echo "<b>URL:</b>";
echo $row["url"];
echo "<br>\n";
echo "<b>Comments:</b>";
echo $row["comments"];
echo "<br>\n";
echo "<br>\n";
echo "<br>\n";
}
mysql_free_result($result);
echo("
<a href=\"sign.php\">Sign my guestbook</a>
");
?>
dbconnect.php is also included on this page, which I'll paste below.
<?
mysql_connect("localhost", "username","password") or
die ("Could not connect to the database");
mysql_select_db("guestbook") or
die ("Could not select database");
?>
Any help would be greatly appreciated. 😃