Jim R Posted Thursday at 07:38 PM Share Posted Thursday at 07:38 PM Up until a week ago the below worked just fine. I migrated my site to a new server space, and now the below is throwing an error. When I remove the GROUP BY, the error goes away. I marked the line throwing the error. Quote Fatal error: Uncaught TypeError: mysqli_fetch_assoc(): Argument #1 ($result) must be of type mysqli_result, bool given in /home1/nitoaute/csi/wp-content/plugins/csi_reviews.php:1088 Stack trace: #0 /home1/nitoaute/csi/wp-content/plugins/csi_reviews.php(1088): $query="SELECT *, e.id as eid,event FROM a_events e INNER JOIN a_players_reviews pr ON pr.eventID = e.id WHERE date_format(start, '%y') = '". $current_season ."' GROUP BY event ORDER BY start desc "; echo '<div class="events_header"><h3>Events & Tournaments</h3></div>'; echo '<div class="events_list">'; $results = mysqli_query($con,$query); LINE 1088 while($line = mysqli_fetch_assoc($results)) { Thank you Quote Link to comment https://forums.phpfreaks.com/topic/326829-dealing-with-an-error-ive-not-seen-before/ Share on other sites More sharing options...
mac_gyver Posted Thursday at 08:27 PM Share Posted Thursday at 08:27 PM the php error you are getting is a follow-on error, because the query is failing, but there is no error handling for the query. the easiest way of adding error handling for all the mysqli statements that can fail - connection, query, exec, prepare, and execute, is to use exceptions for errors (this is the default setting now in php8+). to enabled exceptions for the mysqli extension, add the following line of code before the point where you make the database connection (or upgrade to php8) - mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); you should then be getting an uncaught exception error with the raw database error information in it about a non-groupby/non-aggerate column being referenced. the correct way of fixing this is to a) only select the columns you are using, and b) every column you are selecting needs to be either in the GROUP BY term or used in an aggerate function. there is a database server mode setting that control if this condition produces a query error (the current setting) or if it is just a warning. you may or may not have access to this database mode setting. Quote Link to comment https://forums.phpfreaks.com/topic/326829-dealing-with-an-error-ive-not-seen-before/#findComment-1650189 Share on other sites More sharing options...
Jim R Posted 21 hours ago Author Share Posted 21 hours ago I'm getting a lot of this... Quote Fatal error: Uncaught mysqli_sql_exception: In aggregated query without GROUP BY, expression #55 of SELECT list contains nonaggregated column 'nitoaute_csi.po.id'; this is incompatible with sql_mode=only_full_group_by in /home1/nitoaute/csi/wp-content/plugins/csi_custom.php:1266 The GROUP BYs are what is causing this, at least that's what reflected in the errors. The above code, doesn't have a current instance, but it still shouldn't throw an error. I'm not sure if anything has changed with PHP 8.2 or MySQL 8+ to cause these errors. I read something about a column in the GROUP BY not specifically called in the SELECT. I would say that has never given me an error before, even though it makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/326829-dealing-with-an-error-ive-not-seen-before/#findComment-1650232 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.