Php stmt->;执行();没有给出任何信息,甚至没有错误消息

Php stmt->;执行();没有给出任何信息,甚至没有错误消息,php,Php,刚开始在Stackoverflow上发布脚本,所以请注意我的上传技巧。我正在用php做一个登录和注册代码来连接我的数据库。当我运行stmt->execute()时,什么都没有发生。我尝试了if-else,error(),等等 <?php // begin our session session_start(); //first check that both the username, password and form token have been sent if(!isset

刚开始在Stackoverflow上发布脚本,所以请注意我的上传技巧。我正在用php做一个登录和注册代码来连接我的数据库。当我运行
stmt->execute()
时,什么都没有发生。我尝试了
if-else
error()
,等等

<?php
// begin our session 
session_start();


//first check that both the username, password and form token have been sent 
if(!isset( $_POST['username'], $_POST['password'], $_POST['mailid'], $_POST['firstname'], $_POST['lastname'], $_POST['form_token']))
{
    $message = 'Username and password not valid';
}
// check the form token is valid 

elseif( $_POST['form_token'] != $_SESSION['form_token'])
{
    $message = 'Invalid form submission';
}
elseif (strlen( $_POST['username']) > 20 || strlen($_POST['username']) < 4)
{
    $message = 'Incorrect Length for Username';
}
// check the password is the correct length 
elseif (strlen( $_POST['password']) > 20 || strlen($_POST['password']) < 4)
{
    $message = 'Incorrect Length for Password';
}
// check the username has only alpha numeric characters 
elseif (ctype_alnum($_POST['username']) != true)
{
    // if there is no match ***/
    $message = "Username must be alpha numeric";
}
// check the password has only alpha numeric characters 
elseif (ctype_alnum($_POST['password']) != true)
{
        // if there is no match 
        $message = "Password must be alpha numeric";
}

else
{
    // if we are here the data is valid and we can insert it into database 
    $phpro_username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
    $phpro_password = filter_var($_POST['password'], FILTER_SANITIZE_STRING);
    $phpro_mailid = filter_var($_POST['mailid'], FILTER_SANITIZE_STRING);
    $phpro_firstname = filter_var($_POST['firstname'], FILTER_SANITIZE_STRING);
    $phpro_lastname = filter_var($_POST['lastname'], FILTER_SANITIZE_STRING);
    // now we can encrypt the password 

    $phpro_password = sha1( $phpro_password );

    // connect to database 
    // mysql hostname 
    $mysql_hostname = 'localhost';

    // mysql username 
    $mysql_username = 'root';

    // mysql password 
    $mysql_password = '';

    // database name 
    $mysql_dbname = 'login';


    try
    {
      $dbh = new PDO("mysql:host=$mysql_hostname;dbname=$mysql_dbname", $mysql_username, $mysql_password);
        // $message = a message saying we have connected 

        // set the error mode to excptions 
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        // prepare the insert 
        $stmt = $dbh->prepare("INSERT INTO userdetails (username, mailid, password, firstname, lastname ) VALUES (:phpro_username, :phpro_mailid, :phpro_password, :phpro_firstname, :phpro_lastname)");
        //$stmt = $dbh->prepare("select * from userdetail");

        // bind the parameters 
        $stmt->bindParam(':phpro_username' , $phpro_username );
        $stmt->bindParam(':phpro_password' , $phpro_password );
        $stmt->bindParam(':phpro_mailid'   , $phpro_mailid   );
        $stmt->bindParam(':phpro_firstname', $phpro_firstname);
        $stmt->bindParam(':phpro_lastname' , $phpro_lastname );

        echo "Before execution";
        // execute the prepared statement 
        $stmt->execute();

        //echo "After execution";
        // unset the form token session variable 
        unset( $_SESSION['form_token'] );

        // if all is done, say thanks 
        $message = 'New user added';
    }

         catch(Exception $e)
    {
        // check if the username already exists 
        if( $e->getCode() == 23000)
        {
            $message = 'Username already exists';
        }
        else
        {
            // if we are here, something has gone wrong with the database 
            $message = 'We are unable to process your request. Please try again later"';
        }
    }   
}
?>

尝试在
bindParam
中添加数据类型作为第三个参数:

更改:

$stmt->bindParam(':phpro_username' , $phpro_username );


类似地,其他
bindParams
调用。可以找到更多帮助

尝试在
bindParam
中添加数据类型作为第三个参数:

更改:

$stmt->bindParam(':phpro_username' , $phpro_username );


类似地,其他
bindParams
调用。更多帮助可在中找到

检查$messagecatch@Deep抱歉,没有收到您的邮件。请签入$messagecatch@Deep对不起,我没抓住你。