web_master Posted February 13, 2012 Share Posted February 13, 2012 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 Quote Link to comment Share on other sites More sharing options...
El Chupacodra Posted February 13, 2012 Share Posted February 13, 2012 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? Quote Link to comment Share on other sites More sharing options...
web_master Posted February 13, 2012 Author Share Posted February 13, 2012 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... Quote Link to comment Share on other sites More sharing options...
Adam Posted February 13, 2012 Share Posted February 13, 2012 What's the name of the variable that's undeclared? 0 and 4 are not valid variable names. Quote Link to comment Share on other sites More sharing options...
web_master Posted February 13, 2012 Author Share Posted February 13, 2012 What's the name of the variable that's undeclared? 0 and 4 are not valid variable names. I dont know what is the name, because I see only messages Undeclared variable: "0" or Undeclared variable: "4" Quote Link to comment Share on other sites More sharing options...
El Chupacodra Posted February 13, 2012 Share Posted February 13, 2012 It usually says what row the variable is on too. At least if you have full error reporting on. You might need to enable that. I saw a variable $i but that was declared correctly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.