explode(): Passing null to parameter #2 ($string) of type string is deprecated

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
buhuhu
User
Posts: 221

explode(): Passing null to parameter #2 ($string) of type string is deprecated

Post by buhuhu »

Hello,

I have a table with save file name by ID like this:

$NewFiles = explode(Config("MULTIPLE_UPLOAD_SEPARATOR"), $rsnew["FilesAll"]);
$nextid = ExecuteScalar("SELECT COALESCE(MAX(id),0) +1 CNT FROM tblDocs") ;
$FileCount = count($NewFiles);

  if (trim($NewFiles[0])=='') return TRUE ;
  
for ($i = 0; $i < $FileCount; $i++) {
	if ( trim($NewFiles[$i]) != '') {
		$files = $NewFiles[$i];
		$file_extension = substr(strtolower(strrchr($files, ".")), 1);
		$files = $nextid.   "-files" . "-" .($i + 1). "." . $file_extension;
		$NewFiles[$i] = $files;
	}
}

$sFileName = implode(Config("MULTIPLE_UPLOAD_SEPARATOR"), $NewFiles);
$rsnew['FilesAll'] = $sFileName;

Now error is:

explode(): Passing null to parameter #2 ($string) of type string is deprecated

Can fix that ?

(v2024)

Regards


mobhar
User
Posts: 11905

Post by mobhar »

In which server event did you put that code?


arbei
User
Posts: 9787

Post by arbei »

buhuhu wrote:

$NewFiles = explode(Config("MULTIPLE_UPLOAD_SEPARATOR"), $rsnew["FilesAll"]);

Your $rsnew["FilesAll"] is null, you should check and handle null. You may google the PHP error message for more info about the deprecation since PHP 8.1.


Post Reply