几个小时后它工作得很好,但现在它在浏览器中显示代码而不是执行它。重新检查代码三次,用文件扩展名检查,甚至将整个代码重新输入到一个新的php中,这个bug让我很困扰..
我的代码是这样的:
<?php include('usersign.php'); ?>
<?php
$servername = "localhost";
$dbusername = "root";
$dbpassword = "******";
$dbname = "userdatabase";
$username = $_POST['username'];
$email = $_POST['email'];
$category1 = $_POST['category1'];
$category2 = $_POST['category2'];
$category3 = $_POST['category3'];
$password = $_POST['password'];
$date = date_default_timezone_set('Asia/Kolkata');
$date = date('M-d,Y H:i:s');
$conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO user (username, email, category1, category2, category3, password, date)
VALUES ('$username', '$email', '$category1', '$category2', '$category3', '$password', '$date')";
if ($conn->query($sql) === TRUE) {
echo '<script language="javascript">';
echo 'alert("You have succesfully registerd with userdatabase Please login..")';
echo '</script>';
echo '<a href="usersign.php"></a>';
}
else {
echo "ERROR" . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
任何建议都得到赞赏......
答案 0 :(得分:1)
尝试重新启动您的网络服务器,因为您说它刚刚起作用... 如果它仍然无法正常工作,请检查您的网络服务器日志中的错误,并且您很可能会获得更多有关实际情况的信息。