Jump to content

Is There Any Alternative For Function Implode();


amiyar

Recommended Posts

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

  1. <?php
  2. if($_SERVER['REQUEST_METHOD']=="POST"){
  3. $cnd_id = $_POST["cnd_id"];
  4. $title = $_POST['title'];
  5. $name = $_POST['name'];
  6. $surname = $_POST['surname'];
  7. $contact = $_POST['contact'];
  8. $email_id1 = $_POST['email_id'];
  9. $loc_considered = $_POST['loc_considered'];
  10. $loc_considered1 = implode(', ',$loc_considered);
  11. if($cnd_id>0){
  12. $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";
  13. $obj->query($sql) or die(mysql_error());
  14. }else {
  15. $emailCheck = mysql_query("SELECT email_id FROM tbl_candidate WHERE email_id = '".$email_id1."'");
  16. if (mysql_num_rows($emailCheck) > 0) {
  17. exit('<script type="text/javascript">alert("Email Address Already Exists - Please Try A Different One"); return false; </script>');
  18. }
  19. $sql="INSERT INTO tbl_candidate (title,name,surname,contact_phone,email_id,location_considered) VALUES ('$title','$name','$surname','$contact','$email_id1','$loc_considered1');
  20. $obj->query($sql) or die(mysql_error());
  21. }
  22. header("Location: ./candidatelist.php");
  23. exit();
  24. ?>
     

and this is the form which produces $_POST['loc_considered'] variable.

  1. <tr>
  2. <td>Location Considered </td>
  3. <td align="left" colspan="2">
  4. <?php
  5. $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');
  6. $i=0;
  7. <select name="loc_considered[]" multiple="multiple">
  8. <?php
  9. for($j=1;$j<=(count($loc_con1)-0);$j++)
  10. {
  11. if($loc_con1[$j]== $loc_con[$i])
  12. {
  13. echo '<option value="'.$loc_con1[$j].'" selected="selected">'.$loc_con1[$j].'</option>\n';
  14. $i++;
  15. }
  16. else
  17. {
  18. echo '<option value="'.$loc_con1[$j].'">'.$loc_con1[$j].'</option>\n';
  19. }
  20. }
  21. ?>
  22. </select>
  23. </td>
  24. </tr>

any help tnx in advnc...

Link to comment
Share on other sites

  • 2 weeks later...

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.....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.