Jump to content

Zeux

New Members
  • Posts

    2
  • Joined

  • Last visited

Zeux's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, my code, with php 7.4 - 8.0, works perfectly. It stops to work from php 8.1 because MySQLi's default error mode is changed from MYSQLI_REPORT_OFF to MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT. How can I reproduce the behavior of php 7.4 - 8.0 ? Thank you
  2. Hi to all, this is my environment: OS: Ubuntu 22.04 PHP version; 8.2 PHP Repository: ondrej (deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu/ jammy main) Webserver: Nginx DB: Mariadb 10.10.6 I can connect to Mariadb and execute the query, but if a query returns an error, php stops to continue the code and returns a "Fatal error". My code to connect to Mariadb is: mysqli_report(MYSQLI_REPORT_OFF); $link = mysqli_connect($db_host, "$db_username", "$db_pwd", "$db_name", $db_port, "$db_socket"); and the connection is OK, no problem! As I want to handle the errors, I use the following code: $results=mysqli_query($link, $query); $num_rows=mysqli_num_rows($results) if(!is_numeric($num_rows) OR $num_rows<0) { // Return an error message and exit } // If there is not error the php scrip continue... Now the problem is that the function mysqli_num_rows($results) cause a Fatal error and no other codes is executed. Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in .... TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in ... I know that from PHP 8.1 MySQLi's default error mode is changed from MYSQLI_REPORT_OFF to MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT and therefore, before to connect to Mariadb, I use the command: mysqli_report(MYSQLI_REPORT_OFF) but it doesn't work. Why? Could someone help me, please? Thank you very much!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.