hi all,....

plz help me.....

hi guyz... i just know how to insert a file into database, but i dont know how to update that file....

here is my code....

<?php
        $resume=$_FILES['resume']['name'];
    $file=$_FILES['resume']['tmp_name'];
    $ext=strstr($resume,".");
    //echo "file".$file;
//echo "<br>";
//echo "resume".$resume;
$sql = "SELECT MAX(cnd_id) FROM tbl_candidate";
$res = mysql_query($sql);
$data= mysql_fetch_row($res);
$id = $data[0];
$id = $id+1;

$resumepath = $id.$ext;

//echo $id;
//echo $resumepath;
@move_uploaded_file($file,"http://localhost/tjc%20backup/admin/resume/$resumepath");//file uploading
//echo $email_id;

         $sql="INSERT INTO  tbl_candidate (title,name,surname,contact_phone,email_id,current_employer,key_skills,current_designation,total_experience,relevant_experience, current_location,location_considered,degree, percentage, current_salary,current_benefits,expected_salary, expected_benefits, notice, reason, availability,remarks,extra_remarks,remarks_date,resume,create_date) VALUES ('$title','$name','$surname','$contact','$email_id1','$crnt_employer','$key_skills','$crnt_designation','$ttl_experience','$rel_experience','$crnt_location',
'$loc_considered1".implode(',',$loc_considered)."','$degree','$percentage','$crnt_salary','$crnt_benefits','$exp_salary','$exp_benefits','$notice','$reason','$availability','$remarks','$ext_remarks','$rem_date','$resumepath',CURDATE())";
          $obj->query($sql) or die(mysql_error());
 ?>

tnx... urtrivedi
now its working......
here is my new code....

<?php
if(!empty($resumepath)) {
                  $sql = "SELECT resume FROM tbl_candidate WHERE cnd_id =" .$cnd_id;
                   $res = mysql_query($sql);
                    $data= mysql_fetch_row($res); 
                    $res1 = $data[0];
                    $reset = "../admin/resume/$res1";
                    if(file_exists($reset))
                    {
                        unlink($reset);
                    }

                $resume=$_FILES['resume']['name'];
              $file=$_FILES['resume']['tmp_name'];
              $ext=strstr($resume,".");
     $resumepa = $cnd_id.$ext;
 @move_uploaded_file($file,"../admin/resume/$resumepa");

$sql = "UPDATE tbl_candidate SET resume = '".$resumepa."' WHERE cnd_id = $cnd_id";
 $obj->query($sql) or die(mysql_error());
//echo $sql;
                    }
?>                  
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.