안녕하세요. 제가 왜 아이디어가 없는지 큰 문제가 있습니다 .. 데이터베이스에 파일을 업로드하는 양식이 거의 없습니다. 모두 하나만 제외하고 잘 작동합니다. 같은 쿼리를 모두 사용합니다 (간단한 삽입). 나는 내가 업로드하려고하는 파일과 관련이 있다고 생각하지만 확실하지 않다.데이터베이스에 레코드를 삽입하는 중 SQL 쿼리 오류가 발생했습니다.
DATABASE documents (
reference INT(5) NOT NULL, //it is unsigned zerofill
doc LONGBLOB NOT NULL, //this should contain the binary data
mime_type TEXT NOT NULL // the mime type of the file php allows only application/pdf and image/jpeg
);
그리고 내가 오류는 다음과 같습니다 :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00001, '����' at line 1
UPDATE :
if ($_POST['action'] == 'hndlDocs') {
$ref = $_POST['reference']; // Numeric value of
$doc = file_get_contents($_FILES['doc']['tmp_name']);
$link = mysqli_connect('localhost','XXXXX','XXXXX','documents');
mysqli_query($link,"SET autocommit = 0");
$query = "INSERT INTO documents ({$ref},
'{$doc}',
'{$_FILES['doc']['type']}')
;";
mysqli_query($link,$query);
if (mysqli_error($link)) {
var_dump(mysqli_error($link));
mysqli_rollback($link);
} else {
print("<script> window.history.back(); </script>");
mysqli_commit($link);
}
}
이 데이터베이스는 다음 필드가 있습니다 : 여기
코드입니다SQL 쿼리에 VALUE
을 추가하는 것을 잊어 버린 것을 제외하고는. 파일에서 수집 된 내용에 addslashes()
을 추가해야하며 모두 완료됩니다.
모든 도움을 주실 수 있습니다. 건배!
아래 문서를 읽을 시간이 걸릴하세요? –
Ahhh ... 대단히 감사합니다. 저들을 보았습니다. 남자들 ... 남자들은 ... 내가 바보처럼 보이니 ... –