You are here:  » What's this means

Support Forum



What's this means

Submitted by sbedigital on Thu, 2012-04-26 18:51 in

[26-Apr-2012 18:34:45 UTC] PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/*****/public_html/includes/database.php on line 32
[26-Apr-2012 18:34:45 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/******/public_html/includes/database.php:27) in /home/*****/public_html/html/header.php on line 5

As you can this was really hard to pinpoint what was causing this as this does not refrence to any particular file. So I have decided pair up my http log and php log to what page and which user causing this error by matching up the time and date. It looks like following URL is the problem.
merchant/whatever/32.html

Another word, if you type in or coming from a link that contains nonexistent page number I get this error. Not big deal in ideal world but, when search engine indexed a merchat that had say 320 products, hence producing 32nd page i.e. /merchant/xyz/32.html, but later in the month say same merchant only supplied 240 products, in turn search page can up 24th i.e /merchant/xyz/24.html. Is there way to come aroud this?

Edit: threads merged by support

Submitted by support on Fri, 2012-04-27 08:50

Hello Noor,

It looks like the warning is occurring on paged search result pages so the first thing to do is double check that page numbers within the normal result range are working as expected. Assuming that's OK; enable database debug mode ($config_databaseDebugMode = TRUE; at line 6 of config.advanced.php) and browse one of the pages generating the error again and detailed SQL error information should be displayed. If you're not sure from the query being executed where the problem lies let me know what is displayed and I'll take a look.

It likely related however to your second question; and whilst an error shouldn't occur it would be sensible to 404 pages outside of the result range; which can be done as follows.

To do this, look for the following code at line 342 of search.php:

    $searchresults["products"] = $rows;

...and REPLACE with:

    $searchresults["products"] = $rows;
    if (($page > 1) && ($numRows == 0))
    {
      header("HTTP/1.0 404 Not Found");
      unset($navigation);
      $searchresults = array();
    }

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Fri, 2012-04-27 18:02

I am still getting the same "sent error" I have enabled the dubigging mode on and got following message:

[SELECT id,name,normalised_name,image_url,description,price FROM `products` WHERE id IN ()][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1]

I can assume that, this is because there are no entries in the databse for that page / or id does not exist, that is why I am getting database error. Is there a way to overcome this by implementing code where if entry doest exist them it shows PT's existing html/noresults.php template? rather than your suggested 404 Error page?

Thanks

Submitted by support on Sun, 2012-04-29 17:09

Hello Noor,

I see what's happened - you're using the experimental new index strategy code; and the last version of search.php that I sent to you uses the $resultCount variable to determine whether to continue rather than whether the current page has any results. You should find the following code at line 279:

    if ($resultCount)

...REPLACE this with:

    if ($numRows)

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Mon, 2012-04-30 18:39

Thanks, I'll keep an eye on the log file to this solved the issue.