im using the following code to make a guest book. i can read from my data base but i wanted to keep the entire guestbook in one page. im using functions for writting too it and displaying it but i havnt made all of those yet.
Code: Select all
<?php
function DB() {
$db = mysql_connect("localhost", "root");
return $db;
}
function Gb_Read($Gb_MsgPerPage=20,$Gb_MsgMode=1) {
// Gb_MessageMode = 1 means that the guest book is displayed with post titles and you must click to see each post.
// If it = 0 then each post is is shown on the page in its entirity.
// $gb_MsgPerPage is the number of posts shown per page
$db = mysql_connect("localhost", "root");
mysql_select_db("gbook",DB());
$result = mysql_query("SELECT * FROM posts",DB());
print "<table border=1 ><tr><td>Messages</td></tr>";
$i = 1;
while ($gb = mysql_fetch_array($result)) {
do {
if ( $i > $Gb_MsgPerPage ) {
break; }
print
print "<tr><td>";
print ("<A href=gb.php?GbPage=GbViewPost&id=$gbїID]><B> $gbїTitle] </b> </a> ");
print ("<i>Posted by $gbїPoster]");
print ("On $gbїDate]</i>");
print ("</tr></td>");
$i++;
} while ($gb = mysql_fetch_array($result));
}
print ("</table>");
}
$GbPage = $HTTP_GET_VARSї'GbPage'];
if ($GbPage) {
Switch ($GbPage) {
// Displays info based on the querystring result. This is the meat of the script
case GbViewPost:
echo "View post with ID";
break;
}
}
else {
Gb_Read();
}
?>dont get this error when the querystring has a value. how do i stop this error occuring (mainly the message) as the code works fine just that message keeps coming up..Notice: Undefined index: GbPage in E:\Tom\php work\guestbook\gb.php on line 38
many thanks
Tom
?>