Is my FOR loop causing 500 Internal Server Error
<pre><code>if ($curPage == 1)
{

// WHEN CODE INTRODUCED, PAGE STOPPED WORKING

// for loop for creating midrange pages BELOW current page. if create_midrange is negative, will print nothing
for($create_midrange; $create_midrange &lt; $curPage; $create_midrange++)
{
    if (0 &gt; $create_midrange)
    {}
    else
    {
        echo " &lt;a href='{$_SERVER['PHP_SELF']}?page=$create_midrange'&gt;$create_midrange&lt;/a&gt;";}
    }

    // for loop for creating current page and midrange pages ABOVE. use x as cur page as a marker for starting point otherwise infinite loop. if create_midrange goes beyond totalPages, will break for loop.
    $x = $curPage;
    echo "$x";
    for($curPage; $curPage &lt; ($x + $midrange) || $curPage = $totalPages; $curPage++)
    {
         if ($create_midrange = $curPage)
         {
            echo "$curPage";
         }
         else
         {
            echo "&lt;a href='{$_SERVER['PHP_SELF']}?page=$create_midrange'&gt;$create_midrange&lt;/a&gt;";
         }
    }

    // WHEN CODE INTRODUCED, PAGE STOPPED WORKING

    echo " &lt;a href='{$_SERVER['PHP_SELF']}?page=$totalPages'&gt;$totalPages&lt;/a&gt; ";
    $nextPage = $curPage+1;
    echo " &lt;a href='{$_SERVER['PHP_SELF']}?page=$nextPage'&gt;NEXT &gt;&gt;&lt;/a&gt; ";
}
</code></pre>

<p>introduced this block of code as a general function that would help to create midrange buttons in 3 cases (the shown code only shows 1 case) -> for the first and last page and if the current page is in the middle of the first and last page. i tried looking up my error log but it isn't updated but my webpage gives me a 500 internal error. 
otherwise, my program works fine without that block of code. variables have been checked if they are valid values as part of trial and error already and are set way up in the code at </p>

<pre><code>$midrange = 2;

$create_midrange = $curPage - $midrange;

$curPage = isset($_GET['page']) ? abs($_GET['page']) : 1;

$totalPages = ceil($totalRecords / $results_per_page);

$curPage = ($curPage &gt; $totalPages) ? $totalPages : (int)$curPage;
</code></pre>

<p>if there's anything missing, here's my full code
<a href="http://pastebin.com/ZF4r7Mxb" rel="nofollow">http://pastebin.com/ZF4r7Mxb</a></p>
