Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Whats Wrong?

  1. #1
    New Coder
    Join Date
    Oct 2006
    Location
    north poll
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Whats Wrong?

    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 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">«</a>";
    $finalpage "<a href="?page=$totalpages">»</a>";
    }
    if(
    $page == '1')
    {
    $nv $page+1;
    $nextpage "<a href=?page=$nv>></a>";
    $prevpage "<";
    $firstpage "«";
    $finalpage "<a href="?page=$totalpages">»</a>";
    }elseif(
    $page == $totalpages){
    $pv $page-1;
    $nextpage ">";
    $prevpage "<a href=?page=$pv><</a>";
    $firstpage "<a href="?page=1">«</a>";
    $finalpage "»";
    }
    if(
    $totalpages == '1' || $totalpages == '0'){
    $nextpage ">";
    $prevpage "<";
    $firstpage "«";
    $finalpage "»";
    }
    echo 
    "$firstpage $prevpage Actual Page: $actualpage $nextpage $finalpage
    Pages: $totalpages"
    ;
    ?>
    thanks alot

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •