as a begginer i'm trying to apply a simple guest book tutorial but a problem
everything was fine before starting with mysql :D
i created 3 files:
guest.php
add.php
view.php
in the add.php file, an error in the query
is it right?
$sql= "INSERT INTO $tbl_guest(id, guestname, gender, palce, email, title, comment)VALUES ('$id','$guestname', '$gender', '$place', '$email' ,'$title', '$comment')"; // the error is here
$result=mysql_query($sql);
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='view.php'>View guestbook</a>"; guestbook page
}
else {
echo "ERROR";
}
and an error on view.php file
$result=mysql_query($sql);
while ($rows = mysql_fetch_array($result)) // the error is here
{
$result=mysql_query($sql);
while ($rows = mysql_fetch_array($result)) // the error is here
{
?>
<table border="1" width="50%" id="table1" height="145" align="center">
<tr>
<td rowspan="4">
<p align="left" dir="ltr">Comment Title:
<? echo $rows['title']; ?>
?>
</p>
<p align="left" dir="ltr">Comment: <br>
<? echo $rows['comment']; ?>
</p>
<p align="left" dir="ltr"> </p>
<p align="left" dir="ltr"> </td>
<td width="165">
<p align="center">
<font color="#FF0000" size="5" face="Berlin Sans FB Demi">guest name</font>
</p>
<p align="center">
<? echo $rows['guestname']; ?>
</td>
</tr>
<tr>
<td width="165" align="left">
<p dir="ltr"> <font color ="red"> my place: </font></p>
<? echo $rows['place']; ?>
</td>
</tr>
<tr>
<td width="165" align="left">
<p dir="ltr">gender : </p>
<? echo $rows['gender']; ?>
</td>
</tr>
<tr>
<td width="165" align="left">
<p dir="ltr">email: </p>
<? echo $rows['email']; ?>
</td>
</tr>
</table>
<?
}
mysql_close();
?>
i think i'm writing the code in a wrong way :p


Sign In
Create Account


Back to top









