【发布时间】:2015-06-27 12:52:58
【问题描述】:
我创建了一个 PHP 网站,该网站在我的本地主机上运行良好,但是当我在服务器上上传相同的代码时,它显示服务器上的空白页。
我怀疑的问题是,在我使用数据库连接 (dbc.php) 的代码中,我的页面变得空白。当我删除该数据库连接代码时,一切正常。
我正在输入登录代码和 dbc.php。
我的 login.php 代码
<?php
include('dbc.php');
// get form data, making sure it is valid
$phone = mysql_real_escape_string(htmlspecialchars($_POST['id']));
$pass = mysql_real_escape_string(htmlspecialchars($_POST['password']));
// check to make sure both fields are entered
if ($phone == '' || $pass == '')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';
// if either field is blank, display the form again
header("Location: " .$_SERVER['HTTP_REFERER']);
}
else
{
// save the data to the database
$login_sql=mysql_query("select * from member where email='$phone' and password='$pass'")
or die(mysql_error());
$num=mysql_num_rows($login_sql);
if($num>0)
{
session_start();
$admin_data=mysql_fetch_array($login_sql);
$_SESSION['usermatri_id']=$admin_data['mid'];
if($admin_data['mid']>0)
{
header("Location: dashboard.php");
}
else
{
header("location:".$_SERVER["HTTP_REFERER"]);
}
exit;
}
else{
header("location:".$_SERVER["HTTP_REFERER"]);
}
}
// if the form hasn't been submitted, display the form
?>
我的 dbc.php 代码
<?php
//connection to the database
mysql_connect("localhost","root","")or die(mysql_error('cannot connect'));
mysql_select_db("matrimony");
?>
1) 我试过这些问题,但没有用
PHP redirect not working on server
2) 我也尝试添加错误检查,网页上没有显示任何内容,甚至尝试查看 cPanel 错误日志。
ini_set('display_errors',1);
error_reporting(E_ALL);
【问题讨论】:
-
嘿,伙计,您正在获取 id 并将其分配给电话,然后将其用于电子邮件字段以检查记录。这是一团糟
-
看看这是否有帮助。 mysql 扩展在 php 5.5 php.net/manual/en/function.mysql-select-db.php 中已弃用
-
你的 PHP 版本是多少?你能告诉我你的 phpinfo()
-
@anantkumarsingh 不,我不想从手机中获取任何信息。
-
@TruongHua Php 版本为 5.4.39