sqli准备好的语句不起作用但没有错误

时间:2016-09-17 03:41:34

标签: php mysqli prepared-statement

这段代码上次我检查工作但它现在什么也没做。创建与数据库的连接似乎正在起作用,但是当我将mysqli_stmt_execute($stmt2)放入if语句时,我发现它永远不会返回true并且不起作用。即使在检查mysqli_error($conn);之后也没有发现可见的错误我不知道发生了什么。有什么帮助吗?

 $query = "INSERT INTO TempAcc (FirstName, LastName, Email, Password, Hash)
         VALUES ( ?, ?, ?, ?, ?)";

         $arg1 = $fname;
         $arg2 = $lname;
         $arg3 = $email;
         $arg4 = $pass1;
         $arg5 = $hash;
         $type = "sssss";

        $ini_array = parse_ini_file(realpath(dirname(__FILE__))."/../etc/docs/config.ini");
        $servername = $ini_array['servername'];
        $username = $ini_array['user'];
        $password = $ini_array['pass'];
        $dbname = $ini_array['dbname'];

        $conn = mysqli_connect($servername, $username, $password, $dbname);
        if ($conn->connect_error) {
            exit('An error occured');
        }else{
            print("Connect worked");//always works
        }

             $stmt2 = mysqli_stmt_init($conn);
             mysqli_stmt_prepare($stmt2, $query);
             mysqli_stmt_bind_param($stmt2, $type, $arg1, $arg2, $arg3, $arg4, $arg5);

             print("Hello1");//this prints out!

             if(mysqli_stmt_execute($stmt2)){//this never returns true
                 print("we are in");//this never executes!

             }else{//always goes to else
                 //there are no errors even though it failed
                 echo "<script type='text/javascript'>alert('Did not save');</script>";
             }

编辑:修复和复制

0 个答案:

没有答案