PHP/MySQL Newbie Quesion
Posted: Tue Oct 07, 2003 10:17 am
I have follow a tutorial web site and got some code, when I paste and run it on the http://webmaster.lycos.co.uk/spring85195/, it just keep coming up the error message pasted below.
Warning: Unexpected character in input: ''' (ASCII=92) state=1 in /data/members/free/tripod/uk/s/p/r/spring85195/htdocs/guestbook.php on line 5
Parse error: parse error in /data/members/free/tripod/uk/s/p/r/spring85195/htdocs/guestbook.php on line 5
Here is the code of my impession.html
<br><br><br><br><br><br><br><br><br><br>
<html>
<head><title>PHP workshop on form management: impressions.html</title><head>
<body>
<form method="post" action="guestbook.php">
Your name : <input type="text" name="nom"><br>
Your e-mail : <input type="email" name="email"><br>
Did you <input type="radio" name="impression" value="aime"> lode
<input type="radio" name="impression" value="pasaime"> or not this Website.
<br>
Your comments : <textarea name="commentaires"></textarea>
<br><br>
<input type="submit" name="valider" value="Send">
</form>
</body>
</html>
Here is the guestbook.php
<html>
<head><title>PHP workshop for form management: ajoutimp.php</title><head>
<body>
<?php
$continu=1;
if ($nom == "")
{
print("Your name is needed ");
$continu=0;
}
$db = mysql_connect($localhost,$spring85195,$)
if ($continu == 1)
{
$date=date("Y-m-d");
$sql="INSERT INTO impression (name, email, impression, date, comments) VALUES ('$name', '$email', 'impression', '$date', '$comments')";
mysql_query($sql, $db);
print("Thank you for giving me your impressions !") ;
}
else
{
print("<a href=impressions.html>back</a>");
}
?>
</body>
</html>
Here is the adminimp.php
<br><br><br><br><br><br><br><br><br><br><br> <html>
<head><title>PHP workshop for form management: adminimp.php</title><head>
<body>
<table align="center" cellspacing="0" cellpadding="0" border="1" width="80%">
<tr>
<td bgcolor="black"><font color="white">DATE</td>
<td bgcolor="black"><font color="white">NAME</td>
<td bgcolor="black"><font color="white">EMAIL</td>
<td bgcolor="black"><font color="white">IMPRESSION</td>
<td bgcolor="black"><font color="white">COMMENTS</td>
</tr>
<?php
$db = mysql_connect();
$sql="SELECT * FROM impression ORDER BY date";
$res=mysql_query($sql, $db);
while ($ligne = mysql_fetch_object ($res))
{
print "<tr>";
print "<td>$ligne->date</td>";
print "<td>$ligne->nom</td>";
print "<td>$ligne->email</td>";
print "<td>$ligne->impression</td>";
print "<td>$ligne->comments</td>";
print "</tr>";
}
mysql_free_result ($res);
?>
</table>
</body>
</html>
Many thanks to who will help me or tried to help me out.
Warning: Unexpected character in input: ''' (ASCII=92) state=1 in /data/members/free/tripod/uk/s/p/r/spring85195/htdocs/guestbook.php on line 5
Parse error: parse error in /data/members/free/tripod/uk/s/p/r/spring85195/htdocs/guestbook.php on line 5
Here is the code of my impession.html
<br><br><br><br><br><br><br><br><br><br>
<html>
<head><title>PHP workshop on form management: impressions.html</title><head>
<body>
<form method="post" action="guestbook.php">
Your name : <input type="text" name="nom"><br>
Your e-mail : <input type="email" name="email"><br>
Did you <input type="radio" name="impression" value="aime"> lode
<input type="radio" name="impression" value="pasaime"> or not this Website.
<br>
Your comments : <textarea name="commentaires"></textarea>
<br><br>
<input type="submit" name="valider" value="Send">
</form>
</body>
</html>
Here is the guestbook.php
<html>
<head><title>PHP workshop for form management: ajoutimp.php</title><head>
<body>
<?php
$continu=1;
if ($nom == "")
{
print("Your name is needed ");
$continu=0;
}
$db = mysql_connect($localhost,$spring85195,$)
if ($continu == 1)
{
$date=date("Y-m-d");
$sql="INSERT INTO impression (name, email, impression, date, comments) VALUES ('$name', '$email', 'impression', '$date', '$comments')";
mysql_query($sql, $db);
print("Thank you for giving me your impressions !") ;
}
else
{
print("<a href=impressions.html>back</a>");
}
?>
</body>
</html>
Here is the adminimp.php
<br><br><br><br><br><br><br><br><br><br><br> <html>
<head><title>PHP workshop for form management: adminimp.php</title><head>
<body>
<table align="center" cellspacing="0" cellpadding="0" border="1" width="80%">
<tr>
<td bgcolor="black"><font color="white">DATE</td>
<td bgcolor="black"><font color="white">NAME</td>
<td bgcolor="black"><font color="white">EMAIL</td>
<td bgcolor="black"><font color="white">IMPRESSION</td>
<td bgcolor="black"><font color="white">COMMENTS</td>
</tr>
<?php
$db = mysql_connect();
$sql="SELECT * FROM impression ORDER BY date";
$res=mysql_query($sql, $db);
while ($ligne = mysql_fetch_object ($res))
{
print "<tr>";
print "<td>$ligne->date</td>";
print "<td>$ligne->nom</td>";
print "<td>$ligne->email</td>";
print "<td>$ligne->impression</td>";
print "<td>$ligne->comments</td>";
print "</tr>";
}
mysql_free_result ($res);
?>
</table>
</body>
</html>
Many thanks to who will help me or tried to help me out.