bobsi18 Posted May 20, 2010 Share Posted May 20, 2010 Hi all, would love some help with this error, I'm having a heap of trouble trying to sort it out. Some background: My site is MS2.2, heavily modded. It was running on PHP4 (with register globals on)/MYSQL4 - it is being moved to a new server with register globals off, PHP5.3.1/MYSQL5. I am slowly working through the errors, and am starting to get somewhere, but I'm having trouble with this one. Would love some advice. When accessing the main page (index.php), I get the following error: PHP Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /includes/functions/database.php on line 132 database.php at line 132 shows function tep_db_num_rows($db_query) { return mysql_num_rows($db_query); } There are more errors which I'm working through, but I think this is holding me up on solving the other ones... Link to comment Share on other sites More sharing options...
♥kymation Posted May 20, 2010 Share Posted May 20, 2010 The error is in the bottom part of catalog/index.php, somewhere after this code <?php } else { // default page ?> or in catalog/includes/modules/new_products.php or catalog/includes/modules/upcoming_products.php. Look for a call to tep_db_num_rows(). Something just above that is wrong or missing. Regards Jim See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
MrPhil Posted May 20, 2010 Share Posted May 20, 2010 tep_db_num_rows() is called from two places in /index.php (assuming you've got the right page). One is doing a categories query and the other is the Optional Product List filter. Something went south with the mysql_query() call, resulting in a null result. Do you get any other MySQL error messages? Perhaps, just for debugging, you could change $number_of_categories = tep_db_num_rows($categories_query); to $number_of_categories = tep_db_num_rows($categories_query) || die("error 1: ".mysql_error()); and $filterlist_query = tep_db_query($filterlist_sql); to $filterlist_query = tep_db_query($filterlist_sql) || die("error 2: ".mysql_error()); Hopefully one or the other will tell you about a bad query that you can fix. Presumably the offending code involves some add-on or custom code changes. P.S. There is no "MS2.2". I presume that you are running 2.2 MS2, which is quite out of date. You might want to compare vanilla 2.2 RC2a (the last release) with vanilla 2.2 MS2, and incorporate the changes into your site. Then look around this forum for suggestions on security-related updates you should do, changes needed for MySQL 5, changes needed for PHP 5.3, and random bug fixes (e.g., navigation history). Link to comment Share on other sites More sharing options...
bobsi18 Posted May 21, 2010 Author Share Posted May 21, 2010 Thanks for the reponses. tep_db_num_rows() is called from two places in /index.php (assuming you've got the right page). One is doing a categories query and the other is the Optional Product List filter. Something went south with the mysql_query() call, resulting in a null result. Do you get any other MySQL error messages? Perhaps, just for debugging, you could change $number_of_categories = tep_db_num_rows($categories_query); to $number_of_categories = tep_db_num_rows($categories_query) || die("error 1: ".mysql_error()); and $filterlist_query = tep_db_query($filterlist_sql); to $filterlist_query = tep_db_query($filterlist_sql) || die("error 2: ".mysql_error()); Hopefully one or the other will tell you about a bad query that you can fix. Presumably the offending code involves some add-on or custom code changes. Hmm, I added the || die("error 1: ".mysql_error()); to my site (I actually have 3 instances of it being called: I have added (a long time ago!) a contribution that adds a second manufacturer - so the optional product list filter is basically duplicated), but it doesn't seem to have any effect? I'm not sure if it's related, but when I use the filter to sort by manufacturer, it isn't working (although it does work on my site that is on php4/mysql4). Actually, I just noticed that the error has changed to PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /database.php P.S. There is no "MS2.2". I presume that you are running 2.2 MS2, which is quite out of date. You might want to compare vanilla 2.2 RC2a (the last release) with vanilla 2.2 MS2, and incorporate the changes into your site. Then look around this forum for suggestions on security-related updates you should do, changes needed for MySQL 5, changes needed for PHP 5.3, and random bug fixes (e.g., navigation history). Yes, you're right, I'm running 2.2 MS2 - I must have installed it just before the RC version was released. I have kept up with the security updates, and I do plan on upgrading my site - I was hoping to wait it out and upgrade to Version 3 - but I'm thinking now that might not be a great idea, I might be best to just go with RC2a. Either way, my site is moving to a server with PHP5/MYSQL5 very shortly, so my plan is to get my site running on that, and then work on getting a RC2a version working (I want to start again with a clean install). Link to comment Share on other sites More sharing options...
Guest Posted September 30, 2011 Share Posted September 30, 2011 Hello, Just wondering if there was any resolution with this issue. I've just changed servers from a php4.4.9/mysql4 to a php5.1/mysql5.5.1.56-log, and am having a similar problem PHP Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /includes/functions/database.php on line 100 with the same thing as you on line 100 of my database.php file.... function tep_db_num_rows($db_query) {return mysql_num_rows($db_query); } All I've done is change server with NO other problems after the move. I'm using 2.2RC2a. Gonna keep working on this, error is definitely with the $number_of_categories = tep_db_num_rows($categories_query); part in index.php. Will post here whenever I get a positive result. Link to comment Share on other sites More sharing options...
Guest Posted September 30, 2011 Share Posted September 30, 2011 Well I tracked the problem and solved it. The error was only in the product_info.php file; I'm using a couple of modified queries within the file to see whether something has free shipping, and if it does to tell the customer. Basically I put one too many $product_check = tep_db_fetch_array($product_check_query); lines that weren't required. Seems that the old mysql/php didn't pick up on the error at all and has been working fine all along. Quite possibly bobsi18 's problem was similar? Anyhow an hour or so of detective work pays off. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.