2016-10-03 2 views
1

나는 회원 테이블과 프로필 이미지 파일의 사진에서 필요한 모든 정보가 지금은 데이터베이스에 프로필 사진 주소를 저장하려면 두 개의 테이블에서 데이터를 표시 할하지만 난 내 PHP 스크립트는 여기mySql 쿼리에 문제가 있습니까?

<?php 
error_reporting(E_ALL^E_NOTICE); 
include('configdb.php'); 
if (isset($_POST['submit'])) { 

$target_dir = "../Photos/"; 
$target_file = $target_dir . basename($_FILES["file"]["name"]); 
$uploadOk = 1; 
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); 

if(isset($_POST["submit"])) { 
    $check = getimagesize($_FILES["file"]["name"]); 
    if($check !== false) { 
     echo "File is an image - " . $check["mime"] . "."; 
     $uploadOk = 1; 
    } else { 
     echo "File is not an image."; 
     $uploadOk = 0; 
    } 
} 

if (file_exists($target_file)) { 
    $target_file = $target_dir . rand(1,100000) . basename($_FILES["file"]["name"]); 
    $uploadOk = 1; 
} 



if ($_FILES["file"]["size"] > 600000) { 
    echo "Sorry, your file is too large."; 
    $uploadOk = 0; 
} 

if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" 
&& $imageFileType != "gif") { 
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; 
    $uploadOk = 0; 
} 

if ($uploadOk == 0) { 
    echo "Sorry, your file was not uploaded."; 

} else 
    if(move_uploaded_file($_FILES["file"]["name"], $$target_dir.$target_file)) 
       {  
      mysqli_query($conn,"INSERT INTO profileimage VALUES ('','".$target_file."',''") select p.imageid, p.username,p.imagepath from profileimage p 
      innerjoin member m 
      on m.username=p.username; 

     or die(mysqli_error($conn)); 
       } 
       else { 
     echo "Sorry, there was an error uploading your file."; 
    } 

} 
?> 
입니다 오류 있어 (!) : 구문 오류, 예기치 않은 '실리

가 나는 오류 구문 분석 오류가 발생했습니다

mysqli_query($conn,"INSERT INTO profileimage VALUES ('','".$target_file."',''") select p.imageid, p.username,p.imagepath from profileimage p 
     innerjoin member m 
     on m.username=p.username; 

처럼 내 쿼리를 작성해야 CT '(T_STRING) C에서 : \ WAMP \ WWW 라인 업로드 \ 등록 \의 uploadprofile.php \ 46

난 usernamer가

+0

오류는 무엇입니까? – Epodax

+0

(!) 구문 분석 오류 : 구문 오류, C : \ wamp \ www \ upload \ registration \ uploadprofile.php의 46 번째 줄에있는 예기치 않은 'select'(T_STRING) –

+0

삽입 또는 업데이트 하시겠습니까? – devpro

답변

-1
mysqli_query($conn,"INSERT INTO profileimage select p.imageid, ".$target_file.",p.imagepath from profileimage p 
     innerjoin member m 
     on m.username=p.username; 

    // Remove Value portion And add $target_file value into select query. If you have to insert into perticular field then you have to mention field list also 

부재 테이블 foriegn 키인지 할 방법

INSERT INTO Customers (CustomerName, Country) 
SELECT SupplierName, Country FROM Suppliers; 
0

쿼리에 추가 따옴표 (")가 있었다

mysqli_query($conn,"INSERT INTO profileimage VALUES ('','".$target_file."','') 
select p.imageid, p.username,p.imagepath from profileimage p 
innerjoin member m on m.username=p.username") or die(mysqli_error($conn)); 
+0

thim it give (!) 경고 : getimagesize (Muharram-Babies-Dps-7.jpg) : 스트림을 열지 못했습니다. 12 행의 C : \ wamp \ www \ upload \ registration \ uploadprofile.php에 해당 파일이나 디렉토리가 없습니다. –

+0

쿼리 문제가 해결되었습니다. 다른 오류가 있습니다 ... 이미지의 전체 경로 (Muharram-Babies-Dps-7.jpg)를 추가하십시오. – PravinS

+0

이 줄 오류가 $ check = getimagesize ($ _ FILES [ "file"] ["이름"]); –

관련 문제