title: delete function and upload
body: <p><strong>it must be said that I download the database and all my function is in class.</strong></p>
  
  <p>That's how I was incredible pleased function and think they are nice ..</p>
  
  <p>That's how I'm going to build a gallery where the id of the upload to the site if it fits with the id_session is log in page, you have the option to delete it. and so it must just go back to / latest pictures / when it delete it from the folder and database. but it comes up with an error as you can see here;</p>
  
  <p>Fatal error: Call to a member function bind_param () on a non-object in / home / jesperbo / public_html / mebe.dk / function / function.php on line 411</p>
  
  <p>It is such that I am also in the process of building an upload system where the underlying database and make it smaller after what I have now set it and when it did the 2 things must send me back to / latest-images / but it do not reach the only available picture up on the server and do it with the picture but it will not go back in some way at all. So to / latest-images /</p>
  
  <p>Where wrong with it to delete, etc. I lie just here,</p>
  
  <pre><code>$stm1-&gt;bind_param('i', $id_gallery);
  
  function img_slet_indhold(){
          if($_SESSION["logged_in"] = true &amp;&amp; $_SESSION["rank"] == '1' || $_SESSION["rank"] == 2)
          {
              if($stmt = $this-&gt;mysqli-&gt;prepare('SELECT `title` FROM `gallery` WHERE `id_gallery` = ?'))
              {
                  $stm1-&gt;bind_param('i', $id_gallery);
                  $id_gallery = $_GET["id_gallery"];
  
                  $stm1-&gt;execute();
                  $stm1-&gt;store_result();
                  $stm1-&gt;bind_result($title);
  
                  $UploadDir = "/gallery/";
                  //ligger i toppen af documentet, evt som en define
  
                  if($stm1-&gt;fetch())
                  {
                      $tmpfile = $UploadDir . "" . $title;
                      if(file_exists($tmpfile))
                      {
                          unlink($tmpfile);
                      }
                      $tmpfile = $UploadDir . "lille/" . $title;
                      if(file_exists($tmpfile))
                      {
                          unlink($tmpfile);
                      }
                      $tmpfile = $UploadDir . "store/" . $title;
                      if(file_exists($tmpfile))
                      {
                          unlink($tmpfile);
                      }
                  }
                  $stm1-&gt;close();
              }
              else
              {
                  /* Der er opstået en fejl */
                  echo 'Der opstod en fejl i erklæringen: ' . $mysqli-&gt;error;
              }
          }
  
  
          if($stmt = $this-&gt;mysqli-&gt;prepare('DELETE FROM `gallery` WHERE `id_gallery` = ?' ))
          {
              $stmt-&gt;bind_param('i', $id);
              $id = $_GET["id_gallery"];
  
              $stmt-&gt;execute();
  
              header('Location: /nyeste-billeder/');
  
              $stmt-&gt;close();
  
          }
          else
          {
              /* Der er opstået en fejl */
              echo 'Der opstod en fejl i erklæringen: ' . $mysqli-&gt;error;
          }
      }
  </code></pre>
  
  <p>So into the file as it should delete from, I have chosen to do so here;</p>
  
  <pre><code>&lt;?php 
  session_start();
  require_once ("function/function.php");
  $mebe = new mebe;
  $db = $mebe-&gt;db_c();
  error_reporting(E_ERROR);
  
  $img_slet_indhold = $mebe-&gt;img_slet_indhold();
  
  ?&gt;
  </code></pre>
  
  <p>So when I upload image to folder and database, and just after can be returned when uploading</p>
  
  <pre><code>function img_indhold(){
          if($_SESSION["logged_in"] = true &amp;&amp; $_SESSION["rank"] == '1' || $_SESSION["rank"] == 2)
          {
              include "function/class.upload.php";
              $handle = new Upload($_FILES["filename"]);
  
              if($handle-&gt;uploaded)
              {
                  //lidt mere store billeder
                  $handle-&gt;image_resize = true;
                  $handle-&gt;image_ratio_y = true;
                  $handle-&gt;image_x = 220;
                  $handle-&gt;Process("gallery/store");
  
                  //til profil billede lign..
                  $handle-&gt;image_resize = true;
                  $handle-&gt;image_ratio_crop = true;
                  $handle-&gt;image_y = 115;
                  $handle-&gt;image_x = 100;
                  $handle-&gt;Process("gallery");
  
                  //til profil billede lign..
                  $handle-&gt;image_resize = true;
                  $handle-&gt;image_ratio_crop = true;
                  $handle-&gt;image_y = 75;
                  $handle-&gt;image_x = 75;
                  $handle-&gt;Process("gallery/lille");
                  $pb = $handle-&gt;file_dst_name;
  
              }
              if($stmt = $this-&gt;mysqli-&gt;prepare('INSERT INTO `gallery` (`title`, `id_bruger`) VALUES (?, ?)'))
              {
  
                  $stmt-&gt;bind_param('si', $title, $id_bruger);
                  $title = $pb;
                  $id_bruger = $_SESSION["id"];
  
                  $stmt-&gt;execute();
  
                  header('Location: /nyeste-billeder/');
  
                  $stmt-&gt;close();
  
  
              }
          }
       }
  </code></pre>
  
  <p>So when I call it on the page when it is required to do so do it like this;</p>
  
  <pre><code>&lt;?php 
  session_start();
  require_once ("function/function.php");
  $mebe = new mebe;
  $db = $mebe-&gt;db_c();
  error_reporting(E_ERROR);
  
  $img_slet_indhold = $mebe-&gt;img_slet_indhold();
  
  ?&gt;
  </code></pre>
  
  <p>it is here as to when I will upload to the site and show gallery / pictures on the page</p>
  
  <pre><code>function vise_img(){
          if ($stmt = $this-&gt;mysqli-&gt;prepare('SELECT `id_gallery`, `title`, `id_bruger` FROM `gallery` ORDER BY `gallery`.`id_gallery` DESC')) { 
              $stmt-&gt;execute();
              $stmt-&gt;store_result();
              $stmt-&gt;bind_result($id_gallery, $title, $id_bruger);
  
              while ($stmt-&gt;fetch()) {
                  echo "&lt;div id=\"gallery_box\"&gt;";
                  echo "&lt;a href=\"/profil/$id_bruger/\"&gt;&lt;img src=\"/gallery/$title\" alt=\"\" height=\"115\" width=\"100\" border=\"0\"&gt;&lt;/a&gt;";
                  if($_SESSION["logged_in"])
                  {
                      if($id_bruger == $_SESSION["id"])
                      {
                          echo "&lt;ul&gt;";
                          echo "&lt;li&gt;&lt;a href=\"/nyeste-billeder-slet/$id_gallery/\"&gt;Slet&lt;/a&gt;&lt;/li&gt;";
                          echo "&lt;/ul&gt;";
                      }
                  }
                  echo "&lt;/div&gt;";
              }
  
              /* Luk statement */
              $stmt-&gt;close();
  
          } else {
              /* Der er opstået en fejl */
              echo 'Der opstod en fejl i erklæringen: ' . $mysqli-&gt;error;
          }
      }
  
  
  
  
     function upload_img(){
          if($_SESSION["logged_in"] = true &amp;&amp; $_SESSION["rank"] == '1' || $_SESSION["rank"] == 2)
          {           
          ?&gt;
          &lt;form name="opslag" method="post" action="/nyeste-ok/" enctype="multipart/form-data"&gt;
              &lt;input type="file" name="filename" id="filename" onchange="checkFileExt(this)"&gt;        
              &lt;input name="upload" value="Upload" id="background_indhold" onclick="return check()" type="submit"&gt;
          &lt;/form&gt;
          &lt;?php
          }
          elseif ($_SESSION["logged_in"] != true &amp;&amp; $_SESSION["rank"] != '1' || $_SESSION["rank"] != 2)
          {
              echo "&lt;p&gt;Du har ingen mulighed for at upload billeder på siden&lt;/p&gt;";
          }
  
      }
  </code></pre>
  
  <p><strong>Really hope you are able to help me further!</strong></p>