Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x
Author Message
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1091

PostPosted: Tue Nov 08, 2022 4:38 am Reply with quote

Warning: implode(): Invalid arguments passed in
Warning: preg_replace() expects at least 3 parameters

When I try to edit in admin I get this error.

Code:
   foreach($ShoutArray as $ShoutPart) {

      if (preg_replace("mailto:", $ShoutPart)) { // find mailto:
         $ShoutPart = str_replace("mailto:", "",$ShoutPart); // strip out mailto:
         $ShoutPart = str_replace("%", " ",$ShoutPart);
         $ShoutPart = trim($ShoutPart);
         // decode address to ascii
         $c = 0;
         $AddyArray = explode(" ",$ShoutPart);
         foreach($AddyArray as $AddyPart) {
            $AddyNew[$c] = chr(hexdec($AddyPart));
            $c++;
         }
         $ShoutPart = implode("",$AddyNew);
         $ShoutNew[$i] = "mailto:$ShoutPart"; // add mailto: back in
      } else { $ShoutNew[$i] = $ShoutPart; }
      $i++;
   }
   $ShoutComment = implode(" ", $ShoutNew);


I've never got this error. Any help will be great. Thanks in advance.
 
View user's profile Send private message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1723

PostPosted: Tue Nov 08, 2022 10:21 am Reply with quote

Quote:
Warning: implode(): Invalid arguments passed in


This means, the passed variable in the affected implode function-call is not an array. You have two implodes there. One with $ShoutNew and the other one with $AddyNew. If $ShoutNew and $AddyNew are not already set before the foreach()-loop, you can try to add it before like this to avoid the warning:

php Code:
$AddyNew = array();

$ShoutNew = array();
foreach($ShoutArray as $ShoutPart) {


And the preg_replace function-call can you try to change to preg_match like this:

php Code:
if (preg_match('/mailto:/', $ShoutPart)) { // find mailto:

_________________
Github: RavenNuke 
View user's profile Send private message
hicuxunicorniobestbuildpc







PostPosted: Thu Nov 10, 2022 7:23 pm Reply with quote

Thanks neralex,

What is the function from preg_replace in this case? I can not believe replacing it with preg_match solved the error.

These 2 lines were missing over there. U were right.
Code:
$AddyNew = array();

$ShoutNew = array();


Cheers
 
neralex







PostPosted: Thu Nov 10, 2022 11:27 pm Reply with quote

preg_replace searches subject for matches to pattern and replaces them with replacement. [ Only registered users can see links on this board! Get registered or login! ] But in your case, the script searches only a subject for matches to pattern. There is nothing to replace. preg_math is created exactly for this purpose. [ Only registered users can see links on this board! Get registered or login! ] Therefore, preg_replace is used inconveniently at this point.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©