Jump to content

Undeclared variable


web_master

Recommended Posts

hi,

 

I find a script for a pagination on internet. I cant find the problem, because I got error message "Undeclared variable"

 

<?php 
$per_page = '4'; 

//getting number of rows and calculating no of pages
$QueryReturn = mysql_query(' SELECT * FROM `aktualis` ');
if(!$QueryReturn){ echo mysql_error(); exit; }
$count = mysql_num_rows($QueryReturn);
$pages = ceil($count/$per_page);
?>
<script type="text/javascript">

$(document).ready(function(){

//Display Loading Image
function Display_Load()
{
    $("#loading").fadeIn(900,0);
	$("#loading").html("<img src='images/bigLoader.gif' alt='loader' />");
}
//Hide Loading Image
function Hide_Load()
{
	$("#loading").fadeOut('slow');
};


   //Default Starting Page Results
   
$("#pagination li:first").css({'color' : '#FF0084'}).css({'border' : 'none'});

Display_Load();

$("#content").load("contents/data_aktualis.php?page=1", Hide_Load());



//Pagination Click
$("#pagination li").click(function(){

	Display_Load();

	//CSS Styles
	$("#pagination li")
	.css({'border' : 'solid #dddddd 1px'})
	.css({'color' : '#0063DC'});

	$(this)
	.css({'color' : '#FF0084'})
	.css({'border' : 'none'});

	//Loading Data
	var pageNum = this.id;

	$("#content").load("contents/data_aktualis.php?page=" + pageNum, Hide_Load());
});


});
</script>

<div id="loading" ></div>
<div id="content" ></div>

<ul id="pagination">
<?php 
//Show page links
for($i=1; $i<=$pages; $i++) {
echo '<li id="'.$i.'">'.$i.'</li>';
}
?>
</ul>

 

 

and this is the data file:

 

<?php 
$per_page = '4'; 

if($_GET)
{
$page=$_GET['page'];
}
$start = ($page-1) * $per_page;
$QueryReturn = mysql_query(' SELECT * FROM `aktualis` WHERE `aktualis_delete` = 0 ORDER BY `aktualis_id` LIMIT `"' . $start . '"`,`"' . $per_page . '"`  DESC  ');
if(!$QueryReturn){ echo mysql_error(); exit; }
while($request = mysql_fetch_array($QueryReturn)) {
echo ...
}
?>

 

 

Thnx in advanced for help

Link to comment
https://forums.phpfreaks.com/topic/257013-undeclared-variable/
Share on other sites

Undeclared variables are more of notifications than errors so your script could work anyway.

Usually you just have to declare it by adding a value and you're good to go.

What variable did it say was undeclared?

 

This a pagination script, and when I go on first page (load) then error is Undeclared variable: "0". As You see there is a 4 "loads" per page, and when I go to the next page (click on li) then the error is Undeclared variable: "4"... I hope it is understable...

Link to comment
https://forums.phpfreaks.com/topic/257013-undeclared-variable/#findComment-1317535
Share on other sites

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.