amiyar Posted November 7, 2012 Share Posted November 7, 2012 hi guyz, pls help... is there any alternative for implode();? how to solve this warning??? Warning: implode() [function.implode]: Invalid arguments passed in /home/tjconsul/public_html/admin/actions/act_addcandidate1.php on line 40 this is the code for act_addcandidate1.php <?php if($_SERVER['REQUEST_METHOD']=="POST"){ $cnd_id = $_POST["cnd_id"]; $title = $_POST['title']; $name = $_POST['name']; $surname = $_POST['surname']; $contact = $_POST['contact']; $email_id1 = $_POST['email_id']; $loc_considered = $_POST['loc_considered']; $loc_considered1 = implode(', ',$loc_considered); if($cnd_id>0){ $sql="UPDATE tbl_candidate SET title = '".$title."', name='".$name."', surname = '".$surname."' , contact_phone ='".$contact."', email_id='".$email_id1."',location_considered = '".$loc_considered1."' WHERE cnd_id= $cnd_id"; $obj->query($sql) or die(mysql_error()); }else { $emailCheck = mysql_query("SELECT email_id FROM tbl_candidate WHERE email_id = '".$email_id1."'"); if (mysql_num_rows($emailCheck) > 0) { exit('<script type="text/javascript">alert("Email Address Already Exists - Please Try A Different One"); return false; </script>'); } $sql="INSERT INTO tbl_candidate (title,name,surname,contact_phone,email_id,location_considered) VALUES ('$title','$name','$surname','$contact','$email_id1','$loc_considered1'); $obj->query($sql) or die(mysql_error()); } header("Location: ./candidatelist.php"); exit(); ?> and this is the form which produces $_POST['loc_considered'] variable. <tr> <td>Location Considered </td> <td align="left" colspan="2"> <?php $loc_con1 = array(1=>'ALL','Andaman and Nicobar Islands','Andhra Pradesh', 'Arunachal Pradesh','Assam', 'Bihar','Chandigarh','Chhattisgarh','Dadra and Nagar Haveli','Daman and Diu','Delhi','Goa','Gujarat','Himachal Pradesh','Jammu and Kashmir','Jharkhand','Karnataka','Kerala','Lakshadweep','Madhya Pradesh', 'Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttaranchal','Uttar Pradesh','West Bengal'); $i=0; <select name="loc_considered[]" multiple="multiple"> <?php for($j=1;$j<=(count($loc_con1)-0);$j++) { if($loc_con1[$j]== $loc_con[$i]) { echo '<option value="'.$loc_con1[$j].'" selected="selected">'.$loc_con1[$j].'</option>\n'; $i++; } else { echo '<option value="'.$loc_con1[$j].'">'.$loc_con1[$j].'</option>\n'; } } ?> </select> </td> </tr> any help tnx in advnc... Quote Link to comment https://forums.phpfreaks.com/topic/270394-is-there-any-alternative-for-function-implode/ Share on other sites More sharing options...
Pikachu2000 Posted November 7, 2012 Share Posted November 7, 2012 (edited) Are you sure you're passing an array to implode when you get that error? Edited November 7, 2012 by Pikachu2000 Quote Link to comment https://forums.phpfreaks.com/topic/270394-is-there-any-alternative-for-function-implode/#findComment-1390731 Share on other sites More sharing options...
amiyar Posted November 21, 2012 Author Share Posted November 21, 2012 tnx for ur reply..... pikachu2000... its passing array.... and somehow i fixed that error by changing line 10 like this... $loc_considered = $_POST['loc_considered']; if(isset($_POST['loc_considered'])){ $loc_considered1 = implode(', ',$loc_considered); } now the implode function works only when the $loc_considered isset..... Quote Link to comment https://forums.phpfreaks.com/topic/270394-is-there-any-alternative-for-function-implode/#findComment-1394061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.