更新MySQL中的图像

时间:2018-08-24 12:29:41

标签: php mysql

我想同时更新上载它们的文件夹和数据库的图像,但是我所拥有的代码没有出现在我身上的问题,我只是得到更新数据时的错误脚本,因为我把它在上显示,但是它没有向我显示为什么不更新图像的错误。拜托,如果可以的话-

要更新的表格

<form action="actualizarimg.php" method="post" enctype="multipart/form-data">

<?php while($registro=$resultado->fetch_assoc()) { ?>
<label for="nombre">Nombre</label>
<input type="text" value="<?php echo $registro['nombre']; ?>">
<img height="200px" src="./<?php echo $registro['ruta_imagen']; ?>">
<input type="text" value="<?php echo $registro['ruta_imagen'];?>"
<label for="img">Imágen</label>
<input type="file"> <p>Subir Archivo</p> 
<label>Descripción</label>
<input type="text" value="<?php echo $registro['descripcion']; ?>">
<input type="submit" value="Actualizar">
</form>

要更新的代码

<?php
include('conexion.php');
if(isset($_GET['cve_imagen'])){
    $cve_imagen=$_GET['cve_imagen'];
}
  if(isset($_GET['nombre'])){
    $nombre=$_GET['nombre'];
  }
  if(isset($_GET['descripcion'])){
    $descripcion=$_GET['descripcion'];
  }
   if(isset($_GET['ruta_imagen'])){
    $ruta_imagen=$_GET['ruta_imagen'];

$sql = "UPDATE imagenes SET nombre='$nombre', descripcion='$descripcion', ruta_imagen='$ruta_imagen' WHERE cve_imagen='$cve_imagen' ";
print_r($conexion);
mysqli_query($conexion, $sql);
echo "<script type='text/javascript'>;
alert ('Los datos se actualizaron exitosamente');
window.location='eliminar.php';
</script>";
 }else {
     echo "<script type='text/javascript'>;
alert ('Error al actualizar los datos');
window.location='eliminar.php';
</script>";

 }
 $conexion->close();
 ?>

0 个答案:

没有答案