SyndroneOnline / SyndroneOnline.com

http://syndroneonline.com
0 stars 0 forks source link

mysql_num_rows() expects parameter 1 to be resource #51

Closed emiliobool closed 8 years ago

emiliobool commented 8 years ago

this is an error that has been in there since the beginning and I've been avoiding it, but now that we keep track of logs we need to take care of this

Alert Fired! PHP error on Production/Docker Log
{"v":0,"id":"adb36d7f9090","image":"syndrone-apache","name":"syndrone-apache","line":"[Mon Oct 03 03:51:25.877335 2016] [:error] [pid 37] [client 107.77.169.9:19175] PHP Warning:  mysql_num_rows() expects parameter 1 to be resource, boolean given in /var/www/html/forums/cache/tpl_syndroneskin_site_overlays.html.php on line 197, referer: http://syndroneonline.com/forums/search.php?search_id=egosearch","host":"e3aea404bb6b"}
emiliobool commented 8 years ago

so...

not only this query is called from a template, but it queries all trades just to take mysql_num_rows, instead of just using count(*)

<!-- PHP -->
                                        $query = mysql_query("SELECT count(*) FROM user_trades WHERE trade_author = " . $userdata['user_id'] . " OR trade_recipient = " . $userdata['user_id']);
                                        echo mysql_num_rows($query);
<!-- ENDPHP -->

yes, this is real life.

emiliobool commented 8 years ago

this should be fixed on dev now