php5 and php4 coding difference
Posted: Tue Oct 16, 2007 4:17 am
Everah | Please use the appropriate bbCode tags when posting code in the forums.
Hey there,
I have a search page on my clients site, which searches through mysql database and sends back info with limit of 10 results function. This function works fine on another server with php4 but when i use it on a server with php5, and you click on the "next 10 results link" it just shoots back the same 10 results as before. i am pretty sure this is a syntax issue regarding the differences between php 4 and 5, (but not sure).
Here is the code for the "next 10" function bit:
I am sure the error is this part of the code... any help would be much appreciated thanks you.
Hey there,
I have a search page on my clients site, which searches through mysql database and sends back info with limit of 10 results function. This function works fine on another server with php4 but when i use it on a server with php5, and you click on the "next 10 results link" it just shoots back the same 10 results as before. i am pretty sure this is a syntax issue regarding the differences between php 4 and 5, (but not sure).
Here is the code for the "next 10" function bit:
Code: Select all
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"$PHP_SELF?s=$prevs&q1=$var1&q2=$var2\" class = \"normlinks\"><<
Prev 10</a>  ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
echo " <a href=\"$PHP_SELF?s=$news&q1=$var1&q2=$var2\" class = \"normlinks\">Next 10 >></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
echo "<br><a href=\"search.html\" class = \"normlinks\">Back to Search</a>";
echo "</td></tr></table>";