whats wrong with the function set_title() in my code : <p>I have created a function called set_title(), which is used to set the title and description in the database I don't know where I was wrong </p>

<pre><code>         function set_title($file,$title = "",$description = ""){
           $pathinfo = pathinfo($file);
           $file = $pathinfo['basename'];
           if ($title == "") {
           $title = ucfirst($pathinfo['filename']);
            }
            if ($description !== "") {
            $description = mb_substr($description, 0, 150);
            }
           $sql = "SELECT file, title ,description FROM title  WHERE file = '$file'";
           $con = new mysqli('localhost','root','','jbstore');
           $result = $con-&gt;query($sql);
           if($result-&gt;num_rows &gt; 0){
             $data = $result-&gt;fetch_assoc();
               if($data['description'] == ""){
                 $sql = "INSERT INTO title (description) VALUES('$description')";
                 $con-&gt;query($sql);
               }
           }elseif ($result-&gt;num_rows == 0) {
             $sql = "INSERT INTO title (file,title,description) VALUES ('$file','$title',$description)";
             $result = $con-&gt;query($sql);
           }
         }
</code></pre>

<p>I expected it insert data into database but nothing happens</p>
