2016-08-14 26 views
0

下面是我的代碼,我希望上傳圖像在一個特定的行,所以我想使用where關鍵字在SQL查詢,但是當我在下面的代碼中使用SQL查詢where關鍵字它不工作。請幫助我如何上傳圖像在mysql中使用php與哪裏conditon

<?php 
error_reporting(E_ALL); 
ini_set('display_errors',1); 
if($_SERVER['REQUEST_METHOD']=='POST'){ 
$image=$_FILES['imageup']['tmp_name']; 
$img=file_get_contents($image); 
$con=mysqli_connect('localhost','aish','aish123','photo') or die('Unable To connect'); 
$sql="insert into image (img) values(?)"; 

$stmt=mysqli_prepare($con,$sql); 

mysqli_stmt_bind_param($stmt,"s",$img); 
mysqli_stmt_execute($stmt); 

$check=mysqli_stmt_affected_rows($stmt); 
if($check==1){ 
    $msg = 'Successfullly UPloaded'; 
}else{ 
    $msg = 'Could not upload'; 
} 
mysqli_close($con); 
} 
?> 

回答

0

這聽起來像你想更新,而不是插入。如果記錄已經存在,那麼你需要做一些像'更新image_table SET image_column =:image_data WHERE id =:id'

+0

感謝它正在工作 –