...

View Full Version : Whats Wrong?



LoRd_aLmIghTy
11-13-2006, 11:25 PM
im using this script to show the number of pages but i keep getting an error that says
Parse error: parse error in /****/*********/test.php on line 21
and i have no idea whats wrong it looks fine to me. hopefully more eyes will reveal this nasty error.

heres my code


<?php
$dbuser = '*****';
$dbpass = '*********';
$db = 'db1';
$dbhost = '127.0.0.1';
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db);


$limit = 25;
$page = $_GET['page'];

$totalrows = mysql_num_rows(mysql_query("SELECT user_id FROM users"));

if(empty($page))
{
$page = '1';
}

$start = ($page-1)*$limit;
$start = round($start,0);
echo 'Registered Users:';
$result = mysql_query("SELECT * FROM users LIMIT $start, $limit");
while ($r = mysql_fetch_array($result))
{
echo "$r[user_username]";
}
$totalusers = mysql_num_rows(mysql_query("SELECT user_id FROM users"));
echo "Total Users: ".$totalusers;
$totalpages = $totalrows / $limit;
$totalpages = ceil($totalpages);
if($page == 1)
{
$actualpage = '[1]';
}
else
{
$actualpage = "[$page]";
}
if($page < $totalpages)
{
$nv = $page+1;
$pv = $page-1;
$nextpage = "<a href=?page=$nv>></a>";
$prevpage = "<a href=?page=$pv><</a>";
$firstpage = "<a href="?page=1">&#171;</a>";
$finalpage = "<a href="?page=$totalpages">&#187;</a>";
}
if($page == '1')
{
$nv = $page+1;
$nextpage = "<a href=?page=$nv>></a>";
$prevpage = "<";
$firstpage = "&#171;";
$finalpage = "<a href="?page=$totalpages">&#187;</a>";
}elseif($page == $totalpages){
$pv = $page-1;
$nextpage = ">";
$prevpage = "<a href=?page=$pv><</a>";
$firstpage = "<a href="?page=1">&#171;</a>";
$finalpage = "&#187;";
}
if($totalpages == '1' || $totalpages == '0'){
$nextpage = ">";
$prevpage = "<";
$firstpage = "&#171;";
$finalpage = "&#187;";
}
echo "$firstpage $prevpage Actual Page: $actualpage $nextpage $finalpage
Pages: $totalpages";
?>

thanks alot

ess
11-14-2006, 12:01 AM
Seems that the following line is generating the error.

echo "$r[user_username]";

try and change it to the following.

echo $r["user_username"];

tha,
ess



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum