Re: Help insert not working, implode errors....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Terion Miller wrote:
> I changed the implode to :
> if (isset($_POST['BannerSize'])){$BannerSize = implode(',',
> $_POST['BannerSize']);} else {$BannerSize = "";}
> 
> now it says "Invalid Arguement" whereas when it was the other way it didn't
> 
> 

"Invalid Argument".  Then $_POST['BannerSize'] is not what it is expecting.

Run a is_array() on it before you are using it.
Something like the following should do.

if ( isset($_POST['BannerSize']) && is_array($_POST['BannerSize']) ) {
	$BannerSize = implode(',', $_POST['BannerSize']);
} else {
	$BannerSize = "";
}

You could also go a little further and do something like this...

if ( isset($_POST['BannerSize']) ) {
	if ( is_array($_POST['BannerSize']) ) {
		$BannerSize = implode(',', $_POST['BannerSize']);
	} else {
		$BannerSize = $_POST['BannerSize'];
	}
} else {
	$BannerSize = "";
}

The latter one would assume that you would only receive a valid string
instead of an array if $_POST['BannerSize'] was set at all.

so... YMMV

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux