We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4879
    • 3 Posts
    So this is my snippet file below. I have these access my database to retrieve peoples first & last name and then display on a page. It access’s DB find and results shown on first page. But when I want to go to the next page by either clicking on page number or Next it sends me to a page that says "ERROR: Too many forward attempts!
    The request could not be completed due to too many unsuccessful forward attempts.
    " Anyone know what could be wrong. I’m pretty sure is would be the link id, but I can’t figure out how to get it to work. The code works because I have been running that code for a year with no problems, but with the php id’s its not working.

    <?php
    require_once (’./mysql_connect.php’); // Connect to the db.

    // Number of records to show per page:
    $display = 20;

    // Determine how many pages there are.
    if (isset($_GET[’np’])) { // Already been determined.

    $num_pages = $_GET[’np’];

    } else { // Need to determine.

    // Count the number of records
    $query = "SELECT COUNT(*) FROM users ORDER BY last_name";
    $result = mysql_query ($query);
    $row = mysql_fetch_array ($result, MYSQL_NUM);
    $num_records = $row[0];

    // Calculate the number of pages.
    if ($num_records > $display) { // More than 1 page.
    $num_pages = ceil ($num_records/$display);
    } else {
    $num_pages = 1;
    }

    } // End of np IF.

    // Count the number of records
    $query = "SELECT COUNT(*) FROM users ORDER BY last_name";
    $result = mysql_query ($query);
    $row = mysql_fetch_array ($result, MYSQL_NUM);
    $num_records = $row[0];
    //$num = mysql_num_rows($result);
    echo "<p align=center><b>$num_records - Compadres e Comadres</b></p>";

    // Determine where in the database to start returning results.
    if (isset($_GET[’s’])) {
    $start = $_GET[’s’];
    } else {
    $start = 0;
    }

    // Make the query.
    $query = "SELECT last_name, first_name, user_id FROM users ORDER BY last_name LIMIT $start, $display";
    $result = mysql_query ($query); // Run the query.




    // Table header.
    echo ’<table align="center" cellspacing="0" cellpadding="7">
    <tr>

    <th align="left"><b>Sobrenome</b></th>
    <th align="left"><b>Nome</b></th>
    </tr>
    ’;

    // Fetch and print all the records.
    $bg = ’#eeeeee’; // Set the background color.
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $bg = ($bg==’#eeeeee’ ? ’#ffffff’ : ’#eeeeee’); // Switch the background color.
    echo ’<tr bgcolor="’ . $bg . ’">
    <td align="left">’ . $row[’last_name’] . ’</td>
    <td align="left">’ . $row[’first_name’] . ’</td>
    </tr>
    ’;
    }

    echo ’</table>’;

    mysql_free_result ($result); // Free up the resources.

    mysql_close(); // Close the database connection.

    // Make the links to other pages, if necessary.
    if ($num_pages > 1) {

    echo ’
    <p>’;
    // Determine what page the script is on.
    $current_page = ($start/$display) + 1;

    // If it’s not the first page, make a Previous button.
    if ($current_page != 1) {
    echo ’<a href="index.php?id=15?s’ . ($start - $display) . ’&np=’ . $num_pages . ’">Anterior</a> ’;
    }

    // Make all the numbered pages.
    for ($i = 1; $i <= $num_pages; $i++) {
    if ($i != $current_page) {
    echo ’<a href="index.php?id=15?s=’ . (($display * ($i - 1))) . ’&np=’ . $num_pages . ’">’ . $i . ’</a> ’;
    } else {
    echo $i . ’ ’;
    }
    }

    // If it’s not the last page, make a Next button.
    if ($current_page != $num_pages) {
    echo ’<a href="index.php?id=15?s’ . ($start + $display) . ’&np=’ . $num_pages . ’">Próximo</a>’;
    }

    echo ’</p>’;

    } // End of links section.
    ?>
      • 4041
      • 788 Posts
      Looks to be a few issues in the paging section, use the code below and see if it helps:

      <?php
      
       // If it's not the first page, make a Previous button.
         if ($current_page != 1) {
            echo '<a href="index.php?id=15&s=' . ($start - $display) . '&np=' . $num_pages . '">Anterior</a> ';
         }
      
         // Make all the numbered pages.
         for ($i = 1; $i <= $num_pages; $i++) {
            if ($i != $current_page) {
               echo '<a href="index.php?id=15&s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '">' . $i . '</a> ';
            } else {
               echo $i . ' ';
            }
         }
      
         // If it's not the last page, make a Next button.
         if ($current_page != $num_pages) {
            echo '<a href="index.php?id=15&s=' . ($start + $display) . '&np=' . $num_pages . '">Próximo</a>';
         }
      
         echo '</p>';

        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 4879
        • 3 Posts
        Great that worked. Thank you.

        The only issue I’m still having is with special characters. Where it is suppose to say "João" it says "Jo�o". Any ideas?