PHP空白白页,无错误
我有一个PHP页面,我在本地开发,运行良好。上传到服务器后,我现在只得到一个空白的白色屏幕?这是完全相同的代码,可以在本地正常工作,但不能远程工作。我已经尝试设置错误报告,但仍然没有给我任何错误,只是一个空白的白色屏幕 守则:PHP空白白页,无错误,php,Php,我有一个PHP页面,我在本地开发,运行良好。上传到服务器后,我现在只得到一个空白的白色屏幕?这是完全相同的代码,可以在本地正常工作,但不能远程工作。我已经尝试设置错误报告,但仍然没有给我任何错误,只是一个空白的白色屏幕 守则: $firstname = $phone = $email = $picture = $sqlcon = ""; $firstnameErr = $phoneErr = $emailErr = $pictureErr = $sqlErr
$firstname = $phone = $email = $picture = $sqlcon = "";
$firstnameErr = $phoneErr = $emailErr = $pictureErr = $sqlErr = $filterErr = "";
$statusmsg = "";
$newpicture = $registered = "false";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// If the user has not entered a firstname and has not entered details previously
if ((empty($_POST["firstname"])) && empty($_POST["hfirst"])) {
$firstnameErr = "Firstname is required for submission";
}
else {
if (!empty($_POST["firstname"])) {
$firstname = $_POST["firstname"];
}
else {
$firstname = $_POST["hfirst"];
}
if (!preg_match("/^[a-zA-Z ]*$/", $firstname)) {
$firstnameErr="Please ensure you have entered only characters for your first name";
}
}
// If the user has not entered a phone number and has not entered details previously
if ((empty($_POST["phone"])) && (empty($_POST["hphone"]))) {
$phoneErr = "Please ensure you have entered a phone number";
}
else {
if (!empty($_POST["phone"])) {
$phone = $_POST["phone"];
}
else {
$phone = $_POST["hphone"];
}
if (!is_numeric($phone)) {
$phoneErr = "Please ensure you have entered a valid phone number";
}
}
if ((empty($_POST["email"])) && (empty($_POST["hemail"]))) {
$emailErr = "Please ensure you have entered your email address";
}
else {
if (!empty($_POST["email"])) {
$email = $_POST["email"];
}
else {
$email = $_POST["hemail"];
}
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) {
$emailErr = "Please ensure you have entered a valid email address";
}
}
if ((empty($_FILES["file"]["name"])) && (empty($_POST["hfile"]))) {
$pictureErr = "Please ensure you have selected a picture to upload";
}
else {
if (!empty($_FILES["file"]["name"])) {
if ($_FILES["file"]["size"] > 1048576) {
$pictureErr = "The maximum size for a picture is 1mb";
}
else {
// Ensure the user has selected a file of accepted type
$temp = explode(".", $_FILES["file"]["name"]);
$ext = end($temp);
$allowedExt = array ("gif", "JPEG", "jpg", "png", "JPG");
if (!in_array($ext, $allowedExt)) {
$pictureErr = "Please ensure you have uploaded an image file";
}
}
$newpicture = "true";
$picture = $_FILES["file"]["name"];
}
else {
$picture = $_POST["hpicture"];
}
}
$sqlcon = mysqli_connect("localhost", "USER", "PASS", "personneldb");
if (mysqli_connect_errno()) {
$sqlErr = "Could not connect to database";
mysqli_close($sqlcon);
}
if ($newpicture == "true") {
if (!move_uploaded_file($_FILES["file"]["tmp_name"], "./upload/".$_FILES["file"]["name"])) {
$pictureErr = "File could not be uploaded";
}
}
if ((empty($firstnameErr)) && (empty($emailErr)) && (empty($phoneErr)) && (empty($pictureErr == "")) && (empty($sqlErr == ""))) {
mysqli_query($sqlcon, "INSERT INTO test2Details(Firstname, Phone, Email, ImageName)
VALUES ('$firstname', '$phone', '$email', '$picture')");
// Display status message
$statusmsg = "Success! Your details and picture have been uploaded and stored";
}
if ((!empty($firstname)) && (!empty($phone)) && (!empty($email)) && (!empty($picture))) {
$registered = "true";
}
else {
$registered = "false";
}
}
这将允许在服务器中显示错误,但请记住,不建议在生产环境中使用此选项,也不建议在PHP文件中使用此选项,这些配置必须在PHP.ini中设置
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
有关更多信息,请参见:
:如果您正在使用另一台服务器,这可能是问题所在,请检查此密钥是否存在,否则,请改用$\u服务器[“请求\u方法”]
isset($\u POST)
- 数据库连接?,可能是用户或密码有错误
- 检查PHP错误日志,如果不知道存储在哪里,则执行以下操作:
,应返回错误日志的路径PHP-i | grep error_log
- 检查服务器错误日志,日志通常位于
(服务器可能是lighttpd、apache、nginx、httpd等,具体取决于)/var/log/server
或者,您可以使用ini\u set指令并激活
error\u reporting
这意味着过程已完成。一切都很好,代码结束时没有错误
您应该像
echo“您已经成功创建了”
一样执行操作,可能是服务器设置不正确?可能是PHP通知-确保live PHP.ini文件的“显示错误”设置为“开”。或者,您可以在带有ini_集的代码中执行此操作(“显示错误”,“打开”);把这个放在php.ini@your error repoting line-error\u reporting=~E\u ALL&~E\u DEPRECATED&~E\u STRICT&~E\u NOTICE&~warning我认为问题不在于服务器,因为其他所有文件都显示得很好。我已经尝试了所有的错误报告方法,但仍然没有收到任何错误消息:(似乎$\u服务器
环境未设置。请执行var\u转储($\u服务器)
并查看它返回的内容。在服务器上的php.ini文件中?我没有访问该文件的权限否,您可以将其放在php上file@EduardoVerdugoC阿拉塞雷斯:是的,你可以。但从理论上来说,这不太可能,但考虑到OP描述情况的方式,这是不太可能的。