Hi there,
I used this script about a year ago, i uploaded it again, and for some reason it doesnt seem to want to work any more. Its a guestbook that arranges the submissions into pages each containing 5. I neep getting a parse error on line the following line;
42 echo "<BR>";
43 $pageprev= $page - 1;
44 echo "<A HREF=\"$PHP_SELF?page=$pageprev\"> PREV </A>"; // if page is not equal to one, prev goes to $page - 1
46 }
47 else {
48 echo "<A HREF=\"$PHP_SELF?page=$page\"> PREV </A>"; // Otherwise, PREV reloads the page
49 }
Heres the full script;
<?php
// Log into MySQL database
$db = mysql_connect("localhost", "", "") or die ("Could not connect");
mysql_select_db("kroozin") or die ("Could not select db");
$limit = 5;
$sqlcount= "SELECT id, name, email, location, website, comments FROM guestbook ORDER BY id";
$sql_countresult = mysql_query($sqlcount, $db) or die ("Couldn't execute query");
$totalrows = mysql_num_rows($sql_countresult);
if(empty($page)){
$page = 1;
}
$limitvalue1 = $page*$limit-($limit);
$sql = "SELECT id, name, email, location, website, comments FROM guestbook ORDER BY id LIMIT $limitvalue1, $limit";
$sql_result = mysql_query($sql, $db) or die ("Couldn't execute query");
while ($row = mysql_fetch_array($sql_result)){
echo "Name: <a href='mailto:$row[email]'><b>$row[name]</b></a><br> ";
echo "Email: <b>$row[email]</b><br> ";
echo "Location: <b>$row[location]</b><br> ";
echo "Website: <b>$row[website]</b><br> ";
echo "Comments: <b>$row[comments]</b><br><br> ";
}
echo "<BR>";
$pageprev= $page - 1;
echo "<A HREF=\"$PHP_SELF?page=$pageprev\"> PREV </A>"; // if page is not equal to one, prev goes to $page - 1
}
else {
echo "<A HREF=\"$PHP_SELF?page=$page\"> PREV </A>"; // Otherwise, PREV reloads the page
}
$numofpages = $totalrows/$limit;
for($i= 1; $i < $numofpages+1; $i++) {
echo "<A HREF=\"$PHP_SELF?page=$i\"> $i </A>"; //make number navigation
}
if($totalrows%$limit != 0) {
echo "<A HREF=\"$PHP_SELF?page=$i\"> $i </A>"; ////if there is a remainder, add another page
}
if(($totalrows-($limit$page)) > 0){
$pagenext = $page + 1;
echo "<A HREF=\"$PHP_SELF?page=$pagenext\"> NEXT </A>"; // if the totalrows - $limit $page is > 0 (meaning there is a remainder), leave the next button.
}
mysql_free_result($sql_result);
mysql_close($db);
?>
Thankyou,
Jonathan