title: How to update an image in sql using php
body: <p>I want to update or set a photo on specific user, when I tried to upload an image, the image is not uploaded on my folder "upload"  and the name of the photo (which is a number but 0 e.g: 1.jpg) is inserted in database and the file extension is missing inside the database can someone help me with this</p>
  
  <p>HERE IS MY CODE:</p>
  
  <pre><code>&lt;?php
  session_start();
  include("../db_connection.php");
  
  $seller_id = $_SESSION['seller_id'];
  $trade_name = $_POST ['trade_name'];
  $s_address = $_POST ['s_address'];
  $opening_time = $_POST ['opening_time'];
  $opening_days = $_POST ['opening_days'];
  $order_cutoff = $_POST ['order_cutoff'];
  $seller_delivery_time = $_POST ['seller_delivery_time'];
  $area_covered_delivery = $_POST ['area_covered_delivery'];
  $delivery_fee = $_POST ['delivery_fee'];
  
   $extension = pathinfo($_FILES['s_image']['name'], PATHINFO_EXTENSION);
  
  $sql = mysqli_query($db, "UPDATE selling_details
                     SET
                     opening_time = '$opening_time',
                     opening_days = '$opening_days',
                     order_cutoff = '$order_cutoff',
                     seller_delivery_time = '$seller_delivery_time',
                     area_covered_delivery = '$area_covered_delivery',
                     delivery_fee = '$delivery_fee'
                     WHERE seller_id= '" . $_SESSION['seller_id'] . "' ");
              if ($sql)
      {
          $id = mysqli_insert_id($db);
          $filename = $id.'.'.$extension;
  
          if(move_uploaded_file($_FILES['s_image']['tmp_name'], 'upload/'.$filename))
          {
      }
      else
      {
          echo "error occured : " . mysqli_error($db);
      }
  
  $sql2 = mysqli_query($db, "UPDATE seller
                     SET
                     trade_name = '$trade_name',
                     s_address = '$s_address',
                     s_image = '$filename' 
                     WHERE seller_id= '" . $_SESSION['seller_id'] . "' ");
              if ($sql2)
      {
  
          header('location: seller_menu.php');
      }
      else
      {
          echo "error occured : " . mysqli_error($db);
      }
      }
      ?&gt;
  </code></pre>