Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用PHP将提交的数据保存到MySQL数据库中_Php_Mysql - Fatal编程技术网

无法使用PHP将提交的数据保存到MySQL数据库中

无法使用PHP将提交的数据保存到MySQL数据库中,php,mysql,Php,Mysql,请允许我在这方面寻求一些帮助,因为我已经尝试修复了几天。它在我输入时接受数据,但在我检查时不出现在数据库中 这是我的密码 如果$\u服务器[请求\u方法]==POST{ if (isset($_POST["btnSave"])) { $db = new \dbPlayer\dbPlayer(); $msg = $db->open(); //echo '<script type="text/javascript"> alert("'.$msg.'");&

请允许我在这方面寻求一些帮助,因为我已经尝试修复了几天。它在我输入时接受数据,但在我检查时不出现在数据库中

这是我的密码

如果$\u服务器[请求\u方法]==POST{

if (isset($_POST["btnSave"])) {

    $db = new \dbPlayer\dbPlayer();
    $msg = $db->open();
    //echo '<script type="text/javascript"> alert("'.$msg.'");</script>';
    if ($msg = "true") {
        $userIds = $db->getAutoId("U");
        $flup = new fileUploader\fileUploader();
        $perPhoto = $flup->upload("/hms/files/photos/",$_FILES['perPhoto'], $userIds[1]);
       // var_dump($perPhoto);
        $handyCam=new \handyCam\handyCam();
       if (strpos($perPhoto, 'Error:') === false) {
            $dateNow=date("Y-m-d");
            $data = array(
                'userId' => $userIds[1],
                'name' => $_POST['name'],
                'studentId' => $_POST['studentId'],
                'cellNo' => $_POST['cellNo'],
                'gender' => $_POST['gender'],
                'dob' => $handyCam->parseAppDate($_POST['dob']),
                'passportNo' => $_POST['passportNo'],
                'fatherName' => $_POST['fatherName'],
                'fatherCellNo' => $_POST['fatherCellNo'],
                'perPhoto' => $perPhoto,
                'isActive' => 'Y'
            );
            $result = $db->insertData("studentinfo",$data);
            if($result>=0) {
                 $id =intval($userIds[0])+1;

                    $query="UPDATE auto_id set number=".$id." where prefix='U';";
                    $result=$db->update($query)

使用此表单解决您的问题

     if(isset($_POST["btn-pub"]))
{
    $title = $_POST["title"];
    $cat = $_POST["postCat"];
    $Author = "Imran AKKI";
    $ImgName = $_FILES['PostImg']['name'];
    $ImgTemp = $_FILES['PostImg']['tmp_name'];
    $cont = $_POST["postCon"];
    if (empty($title) || empty($cont)){ 
        ?> 
        <div class="alert alert-danger"><?php echo "Please fill in the fields";  ?>
        </div> 
        <?php
        }elseif($cont > 10000){
            ?> 
        <div class="alert alert-warning"><?php echo "The content of the post is very large";  ?>
        </div> 
        <?php
        }else{
            $postImage = rand(0,10000)."_".$ImgName;
            move_uploaded_file($ImgTemp,"Uploads\postImges\\" .$postImage);

        $query = "INSERT INTO posts(PostTitle, PostCat, PostImg, PostContent,PostAuthor) VALUES ('$title','$cat','$postImage','$cont','$Author')";
        $res=mysqli_query($conn,$query);
        if(isset($res)){
        ?>
        <div class="alert alert-success"><?php echo "The article was added successfully";  ?> </div>
        <?php
        }else{
            ?>
        <div class="alert alert-danger"><?php echo "An error occurred during addition";  ?> </div>
        <?php
        }
    }

    }

您应该提供insertData的功能。$db->open是否返回布尔值或字符串?因为您正在检查$msg=true,这不仅会与字符串进行比较,而且还会将值true指定给$msg,而不会实际检查$msg的值。另外,生成的确切SQL语句是什么?谢谢@Imran AKKI,让我试试请讲一下概念,