Jump to content

Resolved - Random Fatal Error Has Occured


Guest stefkay
 Share

Recommended Posts

Guest stefkay

Hey guys,

I urgently need your help. Today, my website randomly started displaying this message both in admin and on the store :

"Fatal error: Call to undefined function: http_build_query() in /homepages/19/d141433688/htdocs/includes/functions.inc.php on line 471"

http://www.test-meter.co.uk/17th-edition-test-equipment/

I have made changes to the code, but these were done weeks ago and the site has been operating fine.

Also the problem seems to only be shown on pages which use a pagination function?

Any help Much appreciated.

Thanks

Link to comment
Share on other sites

Guest stefkay

I increased the amount of products shown per page and the error message has gone, but now no pagination. Is it clearly a pagination error or something more?

Link to comment
Share on other sites

Guest stefkay

Hi,

Thanks for your reply, we are currently using php version 4.4.9.

How can it work up until now? and is their any fix in which we could stay at our current version of php and have pagination.

Thanks

Link to comment
Share on other sites

The earlier versions of CC4 look like they don't use php5 for that function.. so they -may- work.. not rightly sure. Here's a copy of the entire function, that's in includes/functions.inc.php

Try taking a backup of the file then replacing the function, see if it works

function paginate($numRows, $maxRows, $pageNum=0, $pageVar='page', $class='txtLink', $limit=5, $excluded = array()) {

global $lang;

$navigation = '';



// get total pages

$totalPages = ceil($numRows/$maxRows);



// develop query string minus page vars

$queryString = '';



if (!empty($_SERVER['QUERY_STRING'])) {

  parse_str($_SERVER['QUERY_STRING'], $params);

  foreach ($params as $key => $value) {

   if (!array_key_exists($key, $excluded) && strtolower($key) !== strtolower($pageVar)) {

   # $newParams[$key] = $value;	 # PHP5

    $newParams[] = $key.'='.$value;

   }

  }

  if (!empty($newParams)) {

  # $queryString = http_build_query($newParams); # PHP 5

   $queryString = htmlentities(implode('&', $newParams));

  }

}

 

## Get current page

# $currentPage = basename($_SERVER['PHP_SELF']);

$currentPage = sanitizeVar($_SERVER['PHP_SELF']);



## Build page navigation

if ($totalPages> 1) {

  if(!empty($lang['admin_common']['misc_pages'])) {

   $pageText = $lang['admin_common']['misc_pages'];

  } else {

   $pageText = $lang['front']['misc_pages'];

  }

  $navigation = $totalPages.$pageText;

  $upper_limit = $pageNum + $limit;

  $lower_limit = $pageNum - $limit;



  if ($pageNum > 0) {

   ## Sho, if not the first page

   if (($pageNum - 2)>0) {

    $first = sprintf('%s?%s&%s=%d', $currentPage, $queryString, $pageVar, 0);

    $navigation .= "<a href='".$first."' class='".$class."'>&laquo;</a> ";

   }

   $prev = sprintf('%s?%s&amp;%s=%d', $currentPage, $queryString, $pageVar, max(0, $pageNum - 1));

   $navigation .= "<a href='".$prev."' class='".$class."'>&lt;</a> ";

  }

 

  ## get in between pages

  for ($i = 0; $i < $totalPages; $i++) {

 

   $pageNo = $i+1;

   if ($i==$pageNum) {

    $navigation .= "&nbsp;<strong>[".$pageNo."]</strong>&nbsp;";

   } else if ($i!==$pageNum && $i<$upper_limit && $i>$lower_limit) {

    $noLink = sprintf('%s?%s&amp;%s=%d', $currentPage, $queryString, $pageVar, $i);

    $navigation .= "&nbsp;<a href='".$noLink."' class='".$class."'>".$pageNo."</a>&nbsp;";

   } else if (($i - $lower_limit)==0) {

    $navigation .=  "&hellip;";

   }

  }

   

  if (($pageNum+1) < $totalPages) { // Show if not last page

   $next = sprintf('%s?%s&amp;%s=%d', $currentPage, $queryString, $pageVar, min($totalPages, $pageNum + 1));

   $navigation .= "<a href='".$next."' class='".$class."'>&gt;</a> ";

   if (($pageNum + 3)<$totalPages) {

    $last = sprintf('%s?%s&amp;%s=%d', $currentPage, $queryString, $pageVar, $totalPages-1);

    $navigation .= "<a href='".$last."' class='".$class."'>&raquo;</a>";

   }

  }

}

return $navigation;

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...