Enjoy an ad free experience by logging in. Not a member yet?
Register .
05-19-2008, 01:53 PM
PM User |
#1
Regular Coder
Join Date: Feb 2006
Posts: 262
Thanks: 23
Thanked 1 Time in 1 Post
RESOLVE - array_splice problem.
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 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 !
Last edited by Peuplarchie; 05-19-2008 at 03:26 PM ..
05-19-2008, 02:19 PM
PM User |
#2
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
Where is the definition of that function which starts like
PHP Code:
function array_splice (
Compare the parameter count of this and the function call. That error message is pretty clear!
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
Last edited by abduraooft; 05-19-2008 at 02:23 PM ..
05-19-2008, 03:12 PM
PM User |
#3
Super Moderator
Join Date: Nov 2006
Location: Missouri
Posts: 634
Thanks: 12
Thanked 18 Times in 18 Posts
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()
05-19-2008, 03:19 PM
PM User |
#4
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
Quote:
Originally Posted by
JohnDubya
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()
Thanks for clearing it. I haven't seen it yet
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
05-19-2008, 03:21 PM
PM User |
#5
Super Moderator
Join Date: Nov 2006
Location: Missouri
Posts: 634
Thanks: 12
Thanked 18 Times in 18 Posts
Quote:
Originally Posted by
abduraooft
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.
05-19-2008, 03:22 PM
PM User |
#6
Regular Coder
Join Date: Feb 2006
Posts: 262
Thanks: 23
Thanked 1 Time in 1 Post
You are right guys, only 3 para was allowed.
Thanks for you time !
05-19-2008, 03:29 PM
PM User |
#7
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
Quote:
Originally Posted by
Peuplarchie
You are right guys, only 3 para was allowed.
Thanks for you time !
hey, there are up to 4 in the examples, ?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
05-19-2008, 05:19 PM
PM User |
#8
Super Moderator
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Quote:
Originally Posted by
abduraooft
hey, there are up to 4 in the examples, ?
The third and fourth parameter are optional.
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 02:01 PM .
Advertisement
Log in to turn off these ads.