The code below prints the correct user id of the current user but stores only 0 or 1 into the
database. I don't understand the problem with the code. Your help will be most appreciated
<?php  
 $user_id=print_r($_SESSION["id"]);
      if(isset($_POST['submit'])){ 
          $host = "";
          $db_name = "";
          $username = "";
          $password = "";
          $link=mysqli_connect($host, $username, $password, $db_name);
          //filename as image_path
          $filename=$_FILES['file']['name'];
          $filetmp=$_FILES['file']['tmp_name'];
          $image_title=$_POST['text'];
          $target="uploaded/".$filename;
          $date_time = date('Y-m-d H:i:s');
          $image_url="http://.....".$filename;
              if($filename!=""){
                  $sql="INSERT INTO images (image_path,created,image_url,image_title,user_id) VALUES('$filename','$date_time','$image_url','$image_title','$user_id')";
                  mysqli_query($link,$sql);
                   if(move_uploaded_file($filetmp,$target)){
                       echo "Image uploaded Successfully";
                   }
                   else{
                        echo "Failed to upload !!";
                   }
              }else{
                   echo "Please insert a valid image !!";
              }
      }
 ?>
 
     
     
     
     
    