我觉得我有问题。我的PHP PDO代码根本不起作用。我已经按照手册中的所有内容进行了操作,但它似乎不起作用,只是返回一个空白页面而在我的数据库中根本没有数据。下面是我的PHP代码,我正在使用Xampp。我做错了什么?
<?php
if(isset($_POST["submit"])){
$hostname = 'localhost';
$username = 'root';
$password = '';
try{
$dbh = new PDO ("mysql:host=$hostname;dbname=test", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, ERRMODE_EXCEPTION);
$create_params_query = "INSERT INTO testingdb (name, email, message)
VALUES ('".$_POST["name"]."', '".$_POST["email"]."', '".$_POST["message"]."')";
if($dbh->query($sqlite)){
echo "<script type= 'text/javascript'>alert('You're data has been sent. Thank you!');</script>";
}else{
echo "<script type= 'text/javascript'>alert('Sorry, you're data not being sent. Please try again.');</script>";
}
}catch (PDOException $e){
echo $e->getMessage();
}
}
$dbh = null;
?>