Thundarfoot Posted February 5, 2008 Share Posted February 5, 2008 I have a problem with a script I am working on the script worked until I began trying to add pagination(via dreamweaver) now when I try to change page I get an error. the error msg I get is...Got error 'empty (sub)expression' from regexp. I have a drop down select form in a block whose value when submited gets stored as $name and used in a query via regexp.. basically the script outputs the first 10 results, but when I next page I get the error from the regexp value being empty.. here is the code I am working with, I really appreciate any advice on how to get this working. If I output all records and remove navigation then it works...but when I use navigation it seems the drop down select form loses its value and returns a error. The code is ~100lines sorry for its bloatness. I am not sure what section to focus on. thank you for your time and knowledge. <?php if (!defined('MODULE_FILE')) die('You can\'t access this file directly...'); require_once('mainfile.php'); require_once('../LootWhore/Connections/LWC.php'); $module_name = basename(dirname(__FILE__)); get_lang($module_name); $pagetitle = '- You Module Name'; // If you need this to be multi-lingual then you will have to use language defines include_once 'header.php'; $currentPage = $_SERVER["PHP_SELF"]; $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_LWC, $LWC); $query_Recordset1 = "SELECT * FROM lt_r2_def LEFT OUTER JOIN mobs ON (lt_r2_def.mobid = mobs.id)"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $LWC) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; $queryString_Recordset1 = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_Recordset1") == false && stristr($param, "totalRows_Recordset1") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams)); } } $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1); ?> <html> <body> <div align="center"> <table width="90%" border="0"> <tr> <th colspan="5" scope="col">All Mobs That Drop R2 Defense Cubes </th> </tr> <tr> <table border="1"> <tr> <td>Creature Name</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Recordset1['Creature Name']; ?></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table></td> <td colspan="3" rowspan="3"> </td> </tr> <tr> <td> <table border="0" width="50%" align="center"> <tr> <td width="23%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s&file=R2Deflt", $currentPage, 0, $queryString_Recordset1); ?>"><img src="First.gif" border=0></a> <?php } // Show if not first page ?> </td> <td width="31%" align="center"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s&file=R2Deflt", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"><img src="Previous.gif" border=0></a> <?php } // Show if not first page ?> </td> <td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s&file=R2Deflt&file=R2Deflt", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>"><img src="Next.gif" border=0></a> <?php } // NEXT Show if not last page ?> </td> <td width="23%" align="center"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_Recordset1=%d%s&file=R2Deflt", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>"><img src="Last.gif" border=0></a> <?php } // Show if not last page ?> </td> </tr> </table></td> </tr> <tr> <td> </td> </tr> </table> </div> </body> </html> <?php mysql_free_result($Recordset1); ?> Link to comment https://forums.phpfreaks.com/topic/89614-regexp-loses-value-when-paging/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.