I am not a developer but i have a PHP based system that was developed for me a long time ago. It has been working perfectly fine but all of a sudden i started getting the following errors:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/6/d141070459/htdocs/AcOrdersMix.php on line 67
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /homepages/6/d141070459/htdocs/OrdersMixListU.php on line 154
Sorry to say, but PHP 5.0 has been obsolete for several years. So has MySQL. This is an inflection point in the life of your web site -- maybe a good time to get a professional to help you upgrade to a modern version of the software. It's not easy nor inexpensive, but it's required every few years and you can get a future-proof system that will keep you out of trouble for a while. Technology is always advancing!
Ray Paseur
Here is line 67 of ACOrdersMix (it's the last line in this small snippet).
$sql = "select O.*,DATE_FORMAT(O.order_date1,'%d/%m/%Y') as orderd_date, IF(O.is_manual='1', O.manual_price, 'NULL') AS amount,DATE_FORMAT(O.verified_date,'%D %M %Y') as invoice_date,U.usertitle AS utitle, U.firstname AS ufirstname, U.middlename AS umiddlename, U.lastname AS ulastname, U.companyname, U.addressline1, U.addressline2, U.addressline3, U.addressline4, U.city, U.county AS state, U.postalcode,R.usertitle AS Rtitle, R.firstname AS Rfirstname, R.middlename AS Rmiddlename, R.lastname AS Rlastname, R.companyname AS Rcompanyname, R.addressline1 AS Raddressline1, R.addressline2 AS Raddressline2, R.addressline3 AS Raddressline3, R.addressline4 AS Raddressline4, R.city AS Rcity, R.county AS Rstate, R.postalcode AS Rpostalcode from orders_mix O LEFT JOIN tblusers R ON O.reseller_id=R.userid, tblusers U where ".$asql." O.is_ac='1' and (O.is_acp='0' or O.is_acp IS NULL OR O.is_acp = '') AND O.userid=U.userid group by O.orders_id order by O.orders_id desc"; $rows = mysql_query($sql); $total_results = mysql_num_rows($rows);
This attempts to assign variable $total_results by calling the mysql_num_rows() function with a dependency on the $rows variable. The line above attempts to assign the $rows variable by calling the mysql_query() function with a dependency on the $sql variable that is set on the line above. The programming task here is twofold.
First and most importantly, you must find out why the query failed. To do that, the script should examine the $rows variable, and if it is FALSE, the script should print out the contents of the $sql variable and the contents of the mysql_error() function. I'm slightly amazed that this script has been running all this time without exactly this failure. MySQL is not a black box -- it can and will fail for reasons that are outside of your control and a professionally written script would test for that condition and handle the errors.
Second, once you know what caused the query failure, you can set about remediating that condition.
In either case it will require programming knowledge, since you must change the scripts. This would also be a good time to have a security expert inspect the scripts and advise you about how to "tighten up" the numerous security holes. There are practices in the programming that we haven't used in a decade, owing to the known risks, so now would be a good time to get that fixed, too.
You can probably keep the underlying database and most of the query strings, but a quick inspection tells me that you may want to completely rewrite the application code. It looks beyond repair.
is there an easy way to update the query or is it a case of rewriting it?