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

Php 我需要帮助在个人主页功能,php,Php,我对php有问题。 问题是: 如果您以前看到过代码,可能会看到两个查询函数插入到不同的表中,第一个查询插入时没有任何问题,但是第二个查询不起作用,我不知道为什么请帮助我。 在第一个查询中,我向表中插入了一条新闻的数据,在第二个查询中,我需要插入一张图片,为读者提供更多细节。 代码如下: <?php ob_start(); session_start(); include("../includes/config.php"); if(!$_SESSION[


我对php有问题。
问题是:
如果您以前看到过代码,可能会看到两个查询函数插入到不同的表中,第一个查询插入时没有任何问题,但是第二个查询不起作用,我不知道为什么请帮助我。
在第一个查询中,我向表中插入了一条新闻的数据,在第二个查询中,我需要插入一张图片,为读者提供更多细节。
代码如下:

<?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>


对于第二个查询,请转义列名:

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

因为
for
等名称都是保留的mysql关键字,很明显,您在这个问题上遇到了错误

不起作用,没有提供太多信息。请把你的错误日志也写在问题中。谢谢你的完美回答。