julie_indiana Posted July 17, 2007 Share Posted July 17, 2007 Hi I made a guestbook in php (2.5.3) using sql (4.0.2) And I can't view the name, email and comments I did the same thing on a other website and it works fine! But it's a different web hosting! Can someone help me: here my code: addguestbook.php <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="name"; // Database name $tbl_name="guestbook"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $datetime=date("y-m-d h:i:s"); //date time $sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')"; $result=mysql_query($sql); //check if query successful if($result){ echo "Successful"; echo "<BR>"; echo "<a href='viewguestbook.php'>View guestbook</a>"; // link to view guestbook page } else { echo "ERROR"; } mysql_close(); ?> And code for viewguestbook: <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="name"; // Database name $tbl_name="guestbook"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td>ID</td> <td>:</td> <td><? echo $rows['id']; ?></td> </tr> <tr> <td width="117">Name</td> <td width="14">:</td> <td width="357"><? echo $rows['name']; ?></td> </tr> <tr> <td>Email</td> <td>:</td> <td><? echo $rows['email']; ?></td> </tr> <tr> <td valign="top">Comment</td> <td valign="top">:</td> <td><? echo $rows['comment']; ?></td> </tr> <tr> <td valign="top">Date/Time </td> <td valign="top">:</td> <td><? echo $rows['datetime']; ?></td> </tr> </table></td> </tr> </table> <BR> <? } mysql_close(); //close database ?> Julie Link to comment https://forums.phpfreaks.com/topic/60454-guestbook/ Share on other sites More sharing options...
ShadowMetis Posted July 18, 2007 Share Posted July 18, 2007 I'd recommend changing your webhosting or asking your serveradmin to update php. 2.5.3 is a pretty old version of php and many current functions aren't supported by it. Link to comment https://forums.phpfreaks.com/topic/60454-guestbook/#findComment-300843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.