Issue with php implode function?

JDL12345

New member
My code is:

if($_POST)
{
$ids=implode(",",$_POST["appro"]);
$ids2=implode(",",$_POST["original"]);
$pr=new Products();
$pr->prod_id=$ids;
$pr->prod_id2=$ids2;
$pr->updateAppro();
unset($pr);
}

$_POST["appro"] is an array of checkboxes. The issue I have is that whilst the code works, whenever there are no checkboxes checked, I get the message below because the array is obviously empty.

Warning: implode() [function.implode]: Invalid arguments passed in /homepages/0/d279009625/htdocs/httpdocs/officialcms/stocklist.php on line 39

If I change the 'if' condition to if($_POST["appro"]) then un-check all check boxes, it doesn't enter the if statement as the array is empty and nothing happens. Can anyone enlighten me here?
I tried the solution suggested below but it doesn't perform the function at all. It doesn't give the error but it also doesn't do anything.
The solution I have run with is to switch off errors.
 
Back
Top