2016-08-14 72 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

感谢它正在工作 –