Hi all,
Can anyone please help me with the following code please. My problem is that when I run this code, the name is suppose to appear as a link to the email the person submits, but instead the names appear as numbers, i.e-1,2,3.
<?php
$db_host = "localhost";
$db_user = "root";
$db_password = "";
$db_name = "survey";
$connection = mysql_connect ($db_host, $db_user, $db_password) or die ("error: mysql");
mysql_select_db($db_name, $connection);
$name = $_POST["txt_name"];
$len - strlen($name);
//Only writes to database if there is a name, email and comment entered.
if ($len > 0)
{
$email = $_POST["txt_email"];
$comment = $_POST["txt_comment"];
$query = "INSERT INTO guestbook (name, email, comment) VALUES ('$name', '$email', '$comment')";
mysql_query($query, $connection) or die(mysql_error());
}
?>
<html>
<head>
<title>Welcome to my GuestBook</title>
</head>
<body>
<font size=+4><font color =white><b><i><center>Please Sign my GuestBook!</center></i></b></font>
<body bgcolor="blue">
<center>
<form action="<?php echo $_Server[PHP_SELF]; ?>" method="POST">
<font face = "arial" size ="1">
Name: <input type="text" name = "txt_name">
Email: <input type="text" name = "txt_email"><br><br>
Comments:<br>
<textarea style = "width: 75%" rows = "10" name = "txt_comment"></textarea>
<center><input type ="submit" value="Sign"></center>
</font>
</form>
<table bgcolor="#AAAAAA" border = "0" width = "75%" cellspacing = "1" celloadding = "2">
<?php
$query = "SELECT * FROM guestbook ORDER BY name";
$result = mysql_query($query, $connection);
//Specifies the results from the query.
for ($i =0; $i < mysql_num_rows($result); $i++)
{
$name = mysql_result($result, $i, "name");
$email = mysql_result($result, $i, "email");
$email_len = strlen ($email);
$comment = mysql_result($result, $i, "comment");
$show_comment = nl2br($comment);
Im thinking if its not the code its my php myadmin. If so can anyone tell me the values i should have for my name table?(lenght, attribute, null etc)
Hope to hear from someone soon! Tanx for taking the time to read the thread!