我在个人主页功能方面需要帮助


I have a problem with php.
The problem:
If you saw the code before probably you see two query function that inserting in a different tables, the problem that the first query is inserting without any problem, but the second query doesn't work, I don't know why please help me.
In the first query I insert into a table a data for a news and the second query I need to insert a picture to give more details for the readers.
This is the code:

<?php
    ob_start();
    session_start();
    include("../includes/config.php");
    if(!$_SESSION['admin']){
        header("Location: index.php");
    }
?>
<html>
<body align="center">
<?php
    if(isset($_POST['add'])){
        $title = $_POST['title'];
        $topic = $_POST['topic'];
        if(empty($topic) || empty($title)){
            echo"please don't leave the feilds empty";
        }else{
            //file vars
            $url = $_FILES["upload"]["tmp_name"];
            $path = mysqli_real_escape_string($connect,file_get_contents($url));
            $name = mysqli_real_escape_string($connect,$_FILES["upload"]["name"]);
            $type = mysqli_real_escape_string($connect,$_FILES["upload"]["type"]);
            if(substr($type,0,5) == "image"){
                $sql = "INSERT INTO news(title,topic) VALUES('$title','$topic')";
                $query = mysqli_query($connect,$sql);
                $id = mysqli_insert_id($connect);
                $sqll = "INSERT INTO pic(name,type,content,for) VALUES('$name','$type','$path','$id')";
                $queryy = mysqli_query($connect,$sqll);
                if($query && $queryy){
                    echo"Worked";
                }else{
                    echo"error";
                }
            }else{
                echo"it's not an image";
                echo $type;
            }
        }
    }
?>
<form method="post" action="addnew.php" enctype="multipart/form-data">
    <input type="text" name="title" style="text-align:center" placeholder="title"/><br/>
    <textarea name="topic" placeholder="topic" style="width:800px;height:500px;resize:none;text-align:right;font-size:23">
    </textarea>
    <br/>
    <input type="file" name="upload"/><br/>
    <input type="submit" name="add" value="sed">
</form>
</body>
</html>

For the second query please escape column names:

$sqll = "INSERT INTO pic(`name`,`type`,`content`,`for`) VALUES('$name','$type','$path','$id')";

because such names as for etc. are reserved mysql keywords and you are obviously getting error on this