doutui2016 2018-09-02 03:40
浏览 39
已采纳

不能在PHP中更新图像

<?php
$connect = mysqli_connect("localhost", "root", "", "accounts");
session_start();
$param_email=$_SESSION['email'];
// If session variable is not set it will redirect to login page
if(!isset($_SESSION['email']) || empty($_SESSION['email'])){
  header("location: login.php");
  exit;
}
if(isset($_POST["insert"]))
{
     $file = addslashes(file_get_contents($_FILES["image"]["tmp_name"]));
     $query = "UPDATE users SET image='$file' where email= $param_email";
     if(mysqli_query($connect, $query))
     {
echo '<script>alert("Image Inserted into Database")</script>';
     }
}
?>

I cannot update the image when I put the where but when I remove it it would succefully insert but not update. I need help with this the session email is to check if the user really has logged in or not but the file is the image my only problem is the update. Why is it not working? Thanks :)

  • 写回答

1条回答 默认 最新

  • dqpfkzu360216 2018-09-02 04:22
    关注

    Check this query string.

    $query = "UPDATE users SET image='$file' WHERE email= '$param_email'";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 luckysheet
  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题