Bir resim yüklemesini php üzerinden mysql,
satırına GÜNCELLEŞTIRMEK için kullanıcı kimliğini kullanmaya çalışıyorum. mysql GÜNCELLEME sorgusu php aracılığıyla görüntü yüklemesi için çalışmaz
Sadece dizimi hatası nedir göremiyorum:SQLSTATE[42000]: Syntax error or access violation: 1064 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 '(image_type,image, image_size, image_name) VALUES ('images/1459926006.png','png'' at line 1
Ancak bu hatayı veren tutar.
PHP:
function upload(){
/*** check if a file was uploaded ***/
if(is_uploaded_file($_FILES['userfile']['tmp_name']) && getimagesize($_FILES['userfile']['tmp_name']) != false)
{
/*** get the image info. ***/
$size = getimagesize($_FILES['userfile']['tmp_name']);
/*** assign our variables ***/
$type = $size['mime'];
$imgfp = fopen($_FILES['userfile']['tmp_name'], 'rb');
$size = $size[3];
$name = $_FILES['userfile']['name'];
$maxsize = 99999999;
/*** check the file is less than the maximum file size ***/
if($_FILES['userfile']['size'] < $maxsize)
{
/*** connect to db ***/
$dbh = new PDO("mysql:host=localhost;dbname=table", 'username', 'password');
/*** set the error mode ***/
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*** our sql query ***/
$stmt = $dbh->prepare("UPDATE users (image_type,image, image_size, image_name) VALUES (?,?,?,?) WHERE user_id=?");
/*** bind the params ***/
$stmt->bindParam(1, $type);
$stmt->bindParam(2, $imgfp, PDO::PARAM_LOB);
$stmt->bindParam(3, $size);
$stmt->bindParam(4, $name);
$stmt->bindParam(4, $name);
$stmt->bindParam(5, $_SESSION['user_id']);
/*** execute the query ***/
$stmt->execute();
}
else
{
/*** throw an exception is image is not of type ***/
throw new Exception("File Size Error");
}
}
else
{
// if the file is not less than the maximum allowed, print an error
throw new Exception("Unsupported Image Format!");
}
}
?>
Artık bir hata yok, ancak hala güncelleme yok. Kullanıcı kimliğini yanlış anlamalıyım. – Kez
Evet, oturum kimliğinizi kontrol edin! sayfanızın en üstünde oturuma başladığınızdan emin olun !! – Saty
lol :) Yaptığımdan emin oldum. ama sanırım yanlış yönlendiriyorum. – Kez