PHP code error with version 8

udayasl

New member
I recently tried to upgrade my PHP codes from PHP 7.3 to PHP 8.0.

I am checking error_log and was able to fix a few issues but the following one is still unable to fix.

error_log:

Code:
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in D:\localhost\htdocs\chat\dtc\engine\mysql\board_post_message.php:7 Stack trace: #0 D:\localhost\htdocs\chat\board_post.php(40): include() #1 {main} thrown in D:\localhost\htdocs\chat\dtc\engine\mysql\board_post_message.php on line 7

board_post_message.php has the following code:

Code:
<?php
if (!defined("_COMMON_")) {echo "stop";exit;}
include_once($ld_engine_path."inc_connect.php");
$m_result = mysqli_query($conn,"select concat(subject,body) from ".$mysql_table_prefix."board where user_id=$is_regist") or die("database error: cannot retrieve mail-messages<br>".mysqli_error($conn));
$total = 0;
while ($row = mysqli_fetch_array($m_result, MYSQLI_NUM))
	$total += count($row[0]); 

$percentage = round($total / $max_mailbox_size *100);
mysqli_free_result($m_result);

if ($max_mailbox_size>$total) {
	mysqli_query($conn,"insert into ".$mysql_table_prefix."board (user_id, status, from_nick, from_uid, subject, body, at_date) values($send_to_id, 1, '".addslashes($user_name)."', $is_regist,'".addslashes($subject)."','".addslashes($message)."', ".my_time().")") or die("database error: cannot store new mail-message<br>".mysqli_error($conn));
	mysqli_query($conn,"update ".$mysql_table_prefix."users set new_mails=new_mails+1 where id=$send_to_id") or die("database error: cannot store new mail-message<br>".mysqli_error($conn));;
	$info_message = $w_message_sended;
}
else $info_message = $w_message_error;
?>

Please suggest a fix.

Thank you!
 
Back
Top