Friday, September 6, 2013

Message: implode() [function.implode]: Invalid arguments passed

Message: implode() [function.implode]: Invalid arguments passed

i have form that send data from form to another page by jquery like this:-
<?
$counter=0;
$sqlmasmohType = mysql_query("select * from masmoh");
while ($rowmasmohType = mysql_fetch_array($sqlmasmohType))
{
$counter++;
if($counter % 4 == 0){
$class= "no-margin-left";
}else $class="";
?>
<div class="news-element <?= $class ?>"><input type="checkbox"
id="masmoh" name="masmoh[]" value="<?=$rowmasmohType['id'] ?>"
/>&nbsp;&nbsp;<?=$rowmasmohType['name'] ?></div>
<? } ?>
<div class="clear"></div>
<input type="hidden" name="ft_user_id" id="ft_user_id"
value="<?=$iduser?>" class="input-text">
<input type="button" id="save_masmoh_user" name="save_masmoh_user"
value="Save" class="custom-btn-train-parentt">
this form send to saveMasmohToUser page the 2 argument, one of this
argument is Array and i need to save this Array to database like
(1,5,p,55)
i will try this :-
public function saveMasmohToUser(){
$ft_user_id = $_POST['ft_user_id'];
$save_masmoh = $_POST['save_masmoh'];
$unserializedData = array();
parse_str($save_masmoh,$unserializedData);
if($save_masmoh != ''){
foreach($unserializedData as $unserializedData){
if ($unserializedData != ""){
$check = mysql_query("select count(*) as rowuser from
masmoh_for_user where m_user_id = '".$ft_user_id."'");
$rowUser = mysql_fetch_array($check);
if ($rowUser['rowuser'] == 0)
{
$query = mysql_query("insert into masmoh_for_user (m_user_id,m_masmoh)
values ('$ft_user_id','".implode($unserializedData, ',')."')");
}
else
{
$query = mysql_query("update masmoh_for_user set m_masmoh =
'".implode($unserializedData, ',')."' where m_user_id =
'".$ft_user_id."'");
}
$newData = array();
$newData['msg'] = "save";
$data = json_encode($newData);
echo $data ;
}
}
}
}
but i will see this error :-
Message: implode() [function.implode]: Invalid arguments passed
how can i solve this error.

No comments:

Post a Comment