Jump to content


Check out our Community Blogs

lucky-girl

Member Since 26 Dec 2007
Offline Last Active Oct 25 2008 08:42 AM
-----

Topics I've Started

help on simple guestbook script

31 December 2007 - 12:07 PM

hi everyone

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

new member :)

26 December 2007 - 12:01 PM

hi everybody how r u?

my name is lucky :)

I'm still begginer on programming and i hope to be a real programmer :)

i know some basics on some languages like, Java, c++, ASP.NET and PHP.

step by step i wana learn all of them but starting on php :)

i hope i will get the help here :)..

thanx :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download