...

View Full Version : RESOLVE - array_splice problem.



Peuplarchie
05-19-2008, 02:53 PM
Good day to you all,

I have another problem with my shout box script.

Wrong parameter count for array_splice() in
ERROR LINE : $Data = array_splice($before, 0, 1,$nomcol,$messageq);


Here is my code :



<?php
if (isset($_POST['nameq'])) {

if ($_POST['nameq'] != "" && $_POST['messageq'] != "")
{
$nom = $_POST["nameq"];
$nomcorrecting = strtoupper($nom);
$nomcorr = substr($nomcorrecting, 0, -9);
$messageq = $_POST["messageq"];
$choice = $_POST["COLOUR_CHOICE"];

$handle = @fopen(date('Y')."/".date('m')."/".date('d')."/messages.html", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$before = $buffer;
}
fclose($handle);
}

$nomcol = "<font color=\"#".$choice."\" size=\"3\">".$nomcorr."</font>";


$File = date('Y')."/".date('m')."/".date('d')."/messages.html";
$Handle = fopen($File, 'w+');





$Data = array_splice($before, 0, 1,$nomcol,$messageq);




fwrite($Handle, $Data);

fclose($Handle);


}
}
?>




<form action="" method="post">
<input type="hidden" name="nameq" value="<? echo $_SESSION['Name'];?>"/>
<textarea name="messageq" cols="70" rows="5"></textarea><br/>
<b>Couleur du text : </b>
<?
echo "<select name=\"COLOUR_CHOICE\" id=\"COLOUR_CHOICE\">";

$colourArray = array("000000", "cccc99", "FFFFFF", "0000FF");
for ($i = 0; $i < count($colourArray); $i++)
{
$selected = ($colourArray[$i] == trim($_POST['COLOUR_CHOICE'])) ? 'selected="selected"' : '';
echo '<option value="' . $colourArray[$i] . '"' . $selected . ' . id="opt' . $colourArray[$i] . '">#' . $colourArray[$i] . '</option>';
}
echo "</select>";
?>

<input type="submit" name="Envoyer !!!" value="post"/>
</form>


<br/>

<iframe id="myframe" name="myframe" src="<?php echo date('Y').'/'.date('m').'/'.date('d').'/messages.html'; ?>" scrolling="auto" marginwidth="0" marginheight="0" frameborder="0" style=" width:580px; height:400px;"></iframe>









Thanks again !
Take good care !

abduraooft
05-19-2008, 03:19 PM
Where is the definition of that function which starts like


function array_splice(

Compare the parameter count of this and the function call. That error message is pretty clear!

JohnDubya
05-19-2008, 04:12 PM
Well, array_splice is a built-in PHP function, not a manually created one. Peuplarchie, go here to read about what parameters the array_splice function needs:

array_splice() (http://us2.php.net/array_splice)

abduraooft
05-19-2008, 04:19 PM
Well, array_splice is a built-in PHP function, not a manually created one. Peuplarchie, go here to read about what parameters the array_splice function needs:
array_splice() (http://us2.php.net/array_splice)
Thanks for clearing it. I haven't seen it yet ;)

JohnDubya
05-19-2008, 04:21 PM
Thanks for clearing it. I haven't seen it yet ;)

No prob. I saw your code and thought, "Man, that function looks familiar." lol I never use it personally either.

Peuplarchie, just read over that function's description, and it will help guide you through how to use the array_splice() function.

Peuplarchie
05-19-2008, 04:22 PM
You are right guys, only 3 para was allowed.

Thanks for you time !

abduraooft
05-19-2008, 04:29 PM
You are right guys, only 3 para was allowed.

Thanks for you time ! hey, there are up to 4 in the examples, ?

Inigoesdr
05-19-2008, 06:19 PM
hey, there are up to 4 in the examples, ?
The third and fourth parameter are optional.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum