세션 변수에서 사용자의 user_id를 사용하여 업로드 된 이미지를 mysql에 삽입하려고합니다. 나는 온라인 튜토리얼을 발견하고 아래에 변경 : 내 쿼리의 두 번째 줄에 가진 착오있어PHP를 사용하여 mysql에 이미지 삽입하기
<?php
require_once('../Login/includes/session_timeout_db.inc.php');
$dbuser="";
$dbname="";
$dbpass="";
$dbserver="";
$con = mysql_connect($dbserver,$dbuser,$dbpass);
if (!$con){ die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
// Make sure the user actually
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];
// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
// Create the query and insert
// into our database.
$query = "INSERT INTO images, owner_id";
$query .= "(image) VALUES ('$data', '.$_SESSION['id'].')";
$results = mysql_query($query, $link);
// Print results
print "Thank you, your file has been uploaded.";
}
else {
print "No image selected/uploaded";
}
// Close our MySQL Link
mysql_close($link);
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8” />
<title>Manage Tasks</title>
<link rel="stylesheet" type="text/css" href="../allcss/style.css" />
</head>
<body>
<?php
require('../Login/includes/header.inc.php');
?>
<div id="content">
<form enctype="multipart/form-data" action="" method="post" name="changer">
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
</form>
</div>
</body>
</html>
을 :
$query = "INSERT INTO images, owner_id";
$query .= "(image) VALUES ('$data', '.$_SESSION['id'].')";
$results = mysql_query($query, $link);
* 오류는 구문 분석 오류입니다 : 구문 오류, 예기치 못한 T_ENCAPSED_AND_WHITESPACE, T_STRING 또는 T_VARIABLE 또는 T_NUM_STRING이 (가) 28 호선에서 대기 중임 *
누군가 도와주세요. adnvance에서
덕분에