Jump to content

Notice: Undefined variable: page error! URGENT!


Russia

Recommended Posts

Notice: Undefined variable: page in C:\Program Files (x86)\EasyPHP5.2.10\www\admin.php on line 119

 

That line is:

 

<?php
session_start();
$_SESSION['prev_page'] = $_SERVER['REQUEST_URI'];
if (!session_is_registered('username')) {
    header("location:login.php");
}
?> 



<hr>

<style type="text/css">
table.gridtable {
  color:#333333;
  border-width: 1px;
  border-color: #666666;
  border-collapse: collapse;
        width: 100%;
}
table.gridtable th {
  border-width: 1px;
  padding: 1px;
  border-style: solid;
  border-color: #666666;
  background-color: #dedede;
}
table.gridtable td {
  border-width: 1px;
  padding: 1px;
  border-style: solid;
  border-color: #666666;
}

.valid {
  border-width: 1px;
  padding: 1px;
  border-style: solid;
  border-color: #666666;
  background-color: transparent;
}


</style>
</div>
<div class="newsJustify">
<script type="text/javascript">
   function checkall(delchk)
   {
      for (i = 0; i < delchk.length; i++)
      delchk[i].checked = true;
   }
</script>

<script type="text/javascript">
   function uncheckall(delchk)
   {
      for (i = 0; i < delchk.length; i++)
      delchk.checked = false;
   }
</script>



<script language="JavaScript">
function loadPage(list) {
  location.href=list.options[list.selectedIndex].value
}
</script>


<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("chat") or die(mysql_error());

if (isset($_POST['del'])) {
    for ($count = 0; $count < count($_POST["delchk"]); $count++) {
        $delete = $_POST["delchk"][$count];
        $query  = "DELETE FROM members_shouts WHERE id = '$delete'";
        $result = mysql_query($query);
        if (!$result) {
            die("Error deleting accounts! Query: $query<br />Error: " . mysql_error());
        }
    }
}

$data = mysql_query("SELECT * FROM `members_shouts`") or die(mysql_error());
$rows = mysql_num_rows($data);


if (isset($_GET['limit']))
   {

$page_rows = $_GET["limit"];
if ($page_rows == '') {
    $page_rows = 5; // no double quotes (int) 
} elseif ($page_rows == 'all') {
    $page_rows = $rows; 
} else {
    $page_rows = $_GET['limit']; /* validate this */
}
if (!isset($_GET['pagenum'])) {
    $page = 1;
} else {
    $page = (int) $_GET['pagenum'];
}

}
else
   {
   $page_rows = 10;
   }  

?>

<?php
$max_pages = ceil($rows / $page_rows);
$last      = ceil($rows / $page_rows);
$pagenum   = ($page && $page > 0 && $page <= $last) ? $page : 1;
$max       = 'limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
$data_p = mysql_query("SELECT * FROM members_shouts $max") or die(mysql_error());
?>





<?php
$result = mysql_query("SELECT * FROM members_shouts");
if (mysql_num_rows($result) > 0) {
?>



<span style="float: left;margin-left: 2px;">
<form>
<select name="file" size="1" onchange="loadPage(this.form.elements[0])" target="_parent._top">
            <option value="" <?php
    if ($page_rows == 0) {
        echo 'selected';
    }
?>>Select Limit</option>
            <option value="?limit=9" <?php
    if ($page_rows == 9) {
        echo 'selected';
    }
?>>9</option>
            <option value="?limit=15" <?php
    if ($page_rows == 15) {
        echo 'selected';
    }
?>>15</option>
            <option value="?limit=30" <?php
    if ($page_rows == 30) {
        echo 'selected';
    }
?>>30</option>
            <option value="?limit=all" <?php
    if ($page_rows == 'all') {
        echo 'selected';
    }
?>>All</option>
</select>
</form>
</span>

<span style="float: right;margin-top: 2px;margin-right: 2px;">
<center>
<?php
    if ($pagenum == 1) {
    } else {
        echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1&limit={$page_rows}'>First</a> ";
        echo " | ";
        echo " ";
        $previous = $pagenum - 1;
        $current  = $pagenum;
        echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous&limit={$page_rows}'>$previous</a> ";
        echo " | ";
    }
    echo "$pagenum";
    if ($pagenum == $last || $last == 0) {
    } else {
        $next = $pagenum + 1;
        echo " | ";
        echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next&limit={$page_rows}'>$next</a> ";
        echo " ";
        echo " | ";
        echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last&limit={$page_rows}'>Last</a> ";
    }
?>
</center>
</span>

<style type="text/css">
  .clear2 {
    clear:both;
    height:0px;
    overflow:hidden;
  }
</style>

  <div class="clear2"></div>
<hr>




<?php
    echo "<table class=\"gridtable\">
<thead>
    <tr>
        <th align=\"center\" scope=\"col\">user</th>
        <th align=\"center\" scope=\"col\">message</th>
        <th align=\"center\" scope=\"col\">when</th>
       <th align=\"center\" scope=\"col\">Delete?</th>
    </tr>
</thead>
<tbody>";
    echo "<form name = 'myform' action='' method='post'>";
?>




<?php
    while ($info = mysql_fetch_array($data_p)) {
        echo "<tr align=\"center\">";
        echo "<td class=\"valid\" >" . $info['user'] . "</td>";
        echo "<td class=\"valid\" >" . $info['message'] . "</td>";
        echo "<td>" . $info['when'] . "</td>";
        echo '<td><input type="checkbox" id="delchk" name="delchk[]" value="' . $info['id'] . '" /></td>';
        echo "</tr>";
    }
    echo "</tbody>";
    echo "</table>";
    echo "<hr>";
    echo "<input type='submit' name = 'del' value='Delete Selected'></form>";
    echo "<input type='button' onclick='checkall(document.myform[\"delchk\"]);' value='Select All'>";
    echo "<input type='button' onclick='uncheckall(document.myform[\"delchk\"]);' value='Deselect All'>";
    echo "<hr>";
?>



<?php
} else {
    // No rows were found ...
    echo '<center>No logged accounts.</center><hr>';
}
?> 
</hr>

 

The line its refferring too is:

$pagenum   = ($page && $page > 0 && $page <= $last) ? $page : 1;

 

in this block:

$max_pages = ceil($rows / $page_rows);
$last      = ceil($rows / $page_rows);
$pagenum   = ($page && $page > 0 && $page <= $last) ? $page : 1;
$max       = 'limit ' . ($pagenum - 1) * $page_rows . ',' . $page_rows;
$data_p = mysql_query("SELECT * FROM members_shouts $max") or die(mysql_error());

[/i]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.