2016-08-06 2 views
-1

업데이트 페이지MYSQL (데이터베이스)에서 내 Bio를 어떻게 업데이트합니까?

<?php 


     if(isset($_FILES['profile']) === true){ 
      if(empty($_FILES['profile']['name'])===true){ 
       echo 'Please Choose a file'; 
      }else{ 
       $allowed = array ('jpg','jpeg','gif','png'); 
       $file_name = $_FILES['profile']['name']; 
       $file_extn = strtolower(end(explode('.',$file_name))); 
       $file_temp = $_FILES['profile']['tmp_name']; 

       if (in_array($file_extn, $allowed)===true){ 
        change_profile_image(($_SESSION['accts_id']), $file_temp, $file_extn); 
        header('Location'. $current_file); 
       }else{ 
        echo 'Incorret file type. Allowed: '; 
        echo implode(', ', $allowed); 
       } 
      } 
     } 




     $firstname = getuserfield('firstname'); 
     $profile = getuserfield('Profile'); 

     if(empty($profile ===false)){ 
      echo '<img src="', $profile,'" alt="',$firstname,'\'s Profile Image">'; 
     } 

     if(isset($_POST['textarea'])){ 
      $textarea = $_POST['textarea']; 
      if(!empty($_POST['textarea'])){ 

      change_bio_details($_SESSION['accts_id'], $textarea); 
      header('Location'. $current_file); 
     }else 
     { 
      echo 'Please enter data'; 
     } 

     } 

    ?> 

기능 페이지.

function change_profile_image($accts_id, $file_temp, $file_extn) { 
    $file_path ='imageuploaded/profile/'. substr (md5(time()), 0,10). '.'. $file_extn; 
    move_uploaded_file($file_temp, $file_path); 
    $sql = "UPDATE `accts` SET `Profile` ='". mysql_real_escape_string($file_path) . "' WHERE `id` =" . (int)$accts_id; 
    mysql_query($sql); 
} 

function change_bio_details($accts_id, $textarea){ 
    $sql = "UPDATE `accts` SET `Bio` ='".$textarea."' WHERE `id = ". (int)$accts_id; 
    mysql_query($sql); 
} 
+0

어디서 문제가됩니까? (그 외에 \'마지막 업데이트에서 .... 어디에서 id = ') – Jeff

답변

0

먼저

+0

답장을 보내 주셔서 감사합니다. 마지막 업데이트 때 실종됐다. 그것의 이미 작동. 나는 정말 바보 야. 다시 감사합니다. – Atobe

+0

축하해. 나는 행복하고 운이 좋으면 좋겠다. –

0

당신을 그 파일을 얻을 당신이 여기에 코드 주석을보고 싶다면

내가 그것을 설명 할 수있는 새로운 이미지의 URL을 사용하여 MySQL을 업데이트 입력 파일을 생성 마지막 업데이트 검색어에 간단한 오타가 있습니다.

$sql = "UPDATE `accts` SET `Bio` ='".$textarea."' WHERE `id = ". (int)$accts_id; 

'id'다음에 하나 ssing :

....WHERE `id` = ".... 
+0

예, 알지 못했습니다. 고맙습니다. – Atobe

관련 문제