Jump to content

: implode() [function.implode]: Invalid arguments passed in /home......./admin/i


infoking58

Recommended Posts

Im not sure how to fix this error.

 

Here is the line...

 

<TEXTAREA name="text" rows=20 cols=80>'.stripslashes(implode("",$text)).'</TEXTAREA>

 

 

and the code...?

 

if($q) {

$filename = "../includes/pages/$q";

if(!is_writable($filename)) {

die("<b>$q</b> is not writable! All files in your includes/pages directory should be CHMOD 666");

}

$text = @file($filename,"r");

echo '<b>EDIT PAGE</b> : '.$q.'

<FORM action="index.php" method="POST">

<INPUT type="hidden" name="q" value="'.$q.'">

<TEXTAREA name="text" rows=20 cols=80>'.stripslashes(implode("",$text)).'</TEXTAREA>

<br><INPUT type="submit" name="submit" value="Save page">

</FORM>';

include("footer.php");

exit;

}

 

Any help would be greatly appreciated.  I'm brand new at type of coding.

As Thorpe mentioned, $text is not an array. The underlying problem is that you botched the file() function call: the second parameter should be an integer not a string (see file).

 

The original error is suppressed by the @ in front of the file() call (output in comments):

 

$text = file('test', 'r'); //PHP Warning:  file() expects parameter 2 to be long, string given in php shell code on line 1
var_dump($text); //NULL
implode('', $text); //PHP Warning:  implode(): Invalid arguments passed in php shell code on line 1

$text = file('test');
var_dump($text); /*array(2) {
                               [0]=>
                                    string(6) "line1
                                            "
                               [1]=>
                                   string(6) "line2
                                           "
                              }*/
echo implode('', $text); /*line1
                           line2*/

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.