Hi I have a table with info that I want to read and display.
I can read it and display but I cant seem to format it can anyone tell me whats wrong.
<html>
<head>
<title>comment</title>
</head>
<body>
<form action="postcomment.php" method="post">
name: <input type="text" name="name" ><br>
comment: <textarea name= "comment" type = "text"></textarea><br>
<input type="submit" name="submit value="submit">
</form>
</body>
</html>
<?php
$server = "localhost"; // server to connect to.
$database = ""; // the name of the database.
$db_user = ""; // mysql username to access the database with.
$db_pass = ""; // mysql password to access the database with.
$table = "comment";
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
// insert the data
$insert = mysql_query("insert into $table values ('NULL', '".$_POST['name']."', '".$_POST['comment']."')")
or die("Could not insert data because ".mysql_error());
// print a success message
echo "Your comment was posted!<br>";
?>
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="comment"; // Table name
// connect to the mysql server
$link = mysql_connect($host, $username, $password)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
$db_found = mysql_select_db($db_name)
or die ("Could not select database because ".mysql_error());
$result=mysql_query("select * from $tbl_name");
while($row=mysql_fetch_assoc($result)){
echo "ID: $row['id'] <br/>";
echo "name :$row['name'] <br/>";
echo "comment: $row['comment'] <br/>";
}
}
?>
CREATE TABLE `comment` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
`comment` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
i get this error
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
please can someone have a look and tell me how i can format the output thank you.