comboy
Instructor
- May 23, 2003
- 226
Hi all,
Hope some one can help me here I am developing a guestbook for a college project and am getting the following error
Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Program Files\Apache Group\Apache2\htdocs\guestbook\guestbook.php on line 100
The origional code I'm looking at was written in php 4 but I'm using php and MySQL 5 but don't think that should make much of a difference
I know it more than likely something small but I just can't see it.
Here is my code
All help greatly appreciated
Graham
Hope some one can help me here I am developing a guestbook for a college project and am getting the following error
Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Program Files\Apache Group\Apache2\htdocs\guestbook\guestbook.php on line 100
The origional code I'm looking at was written in php 4 but I'm using php and MySQL 5 but don't think that should make much of a difference
I know it more than likely something small but I just can't see it.
Here is my code
Code:
<?php
require ($_SERVER['DOCUMENT_ROOT']."/guestbook/config/db_config.php");
$connection = mysql_connect($db_host, $db_user, $db_pass) or die("Sorry we can not connect to the database at the moment");
mysql_select_db ($db_name, $connection);
$name = $_POST("txt_name");
$len = strlen ($name);
if ($len > 0)
{
$email = $_POST ("txt_email");
$comment = $_POST ("txt_comment");
$date = time ();
$query = "INSERT INTO guestbook (autoid, name, email, comment, date_auto) VALUES (NULL, '$name', '$email', '$comment', '$date')";
mysql_query ($query, $connection) or die (mysql_error());
}
?>
<html>
<head>
<title>guestbook</title>
</head>
<body>
<table width="70%" border="0" align="center">
<tr>
<td>Welcome to</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><form method="post" action="<?php echo $_SERVER['php_self'];?>">
<table width="100%" border="0" align="center" bgcolor="#CCCCCC">
<tr>
<td width="13%">Name:</td>
<td width="87%"><input name="txt_name" type="text" id="txt_name"></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="txt_email" type="text" id="txt_email"></td>
</tr>
<tr>
<td>Comments:</td>
<td><textarea name="txt_comment" cols="50" rows="10" id="txt_comment"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
<td> </td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p> </P>
<table width="70%" border="0" align="center" cellpadding="1" cellspacing="2">
<?php
$query = "SELECT * FROM guestbook ORDER BY date_auto";
$result = mysql_query ($query, $connection);
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");
$comment =nl2br ($comment);
$date = mysql_result($result, $i, "date_auto");
$show_date = date("H:i:s m/d/Y", $date);
if ($i % 2)
{
$bg_color="#ffcc00";
}
else
{
$bg_color="#fffff";
}
echo '
<tr>
<td width="100%" bgcolor="'.$bgcolor.'">
<font face="ariel" size="2">';
if ($email_len > 0)
{
echo '<b> Name: </b> <a href="mailto:.'$email'.'">'.$name.'</a>';
}
else
{
echo '<b> Name: </b>'.$name;
}
echo '<br>
<b> Comments: </b>'.$comment.'
</font>
<td>
<td width="1%" valign="top" nowrap bgcolor="'.bg_color.'">
<font face="ariel" size="2">
<b> Date: </b>'.$show_date.'
</font>
</td>
</tr>
';
}
?>
</table>
</body>
</html>
All help greatly appreciated
Graham