- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我创建了一个 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);
最佳答案
下面的代码是非常非常错误的...
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{
//the juice...
}
上面的意思是如果:
$_POST['id'] = 123456;
$_POST['password'] = 123456;
我还能喝“果汁”
a) 确保 MySql 服务器已启动并正在运行。
b) 确保您尝试访问的数据库和表已正确导入。
c) 还要确保您有权访问该特定数据库。
从小做起
只需将以下内容添加到您的脚本中:
ini_set('display_errors',1);
error_reporting(E_ALL);
mysql_connect("localhost","root","")or die(mysql_error('cannot connect'));
mysql_select_db("matrimony");
有什么错误吗?不,很好,继续添加小块代码,直到您找到造成您生命中浪费的 3 天的罪魁祸首。
在尝试了上面的方法之后,我要重复一遍,在尝试上面的方法之后如果你还有问题,请在我的答案下方评论,我会尽力帮助你。
关于php - 页面在本地主机上运行良好但无法在托管服务器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29753955/
我在这里想做的是将所有连接转发到机器一上端口 3306 上的本地主机到本地主机上端口 3306 上的机器二。因此,如果您连接到机器一上的 mysql,它的行为就像您正在连接一样在二号机器上。 我认为
通过Kibana界面,如何获得 flex IP /主机? 我的意思是,与kibana连接的Elastic主机。 那有可能吗?我在这个上挣扎了好几个小时,却一无所获:( 附:不确定此问题是否是题外话,应
我知道这听起来很奇怪,但我有一个情况,Deno 需要关闭自己的主机(并因此杀死自己的进程)。这可能吗? 我特别需要这个用于 linux (lubuntu),如果相关的话。我想这需要 sudo 权限,这
我知道这听起来很奇怪,但我有一个情况,Deno 需要关闭自己的主机(并因此杀死自己的进程)。这可能吗? 我特别需要这个用于 linux (lubuntu),如果相关的话。我想这需要 sudo 权限,这
我有一个基本问题,但谷歌并没有为我产生很多结果(反正不是英文的)。基本上我想做的就是: 我有一个图形需要用作整个应用程序的持久 header ,例如:我不能让它在新的 Intent 调用时从屏幕上滑出
您好,我正在使用 xampp,我正在尝试使用 php 进行连接。 $sql_connections = mysql_connect("$server, $username, $password")
我目前正在尝试一些多人游戏的想法,并正在尝试创建一个 Java 应用程序来为基于网络浏览器的多人游戏提供服务。 我的开发环境是主机上的Eclipse, native 上的notepad + Googl
今天为大家分享一篇关于SSH 的介绍和使用方法的文章。本文从SSH是什么出发,讲述了SSH的基本用法,之后在远程登录、端口转发等多种场景下进行独立的讲述,希望能对大家有所帮助。 什么是SSH?
我已经完成了在裸机 Centos 7 上运行的测试 Kubernets 主机的设置。这将用作测试系统,因为我们将在 IBM Bluemix Kubernetes 服务中部署所有内容。 从 Bluemi
我正在尝试通过带有 4.2(果冻 bean )的 android 设备“nexus 7”通过 USB 与我的 freeduino 板进行通信,该板类似于 arduino uno。 几个月后,我使用开发
我正在使用 nginx,但在设置反向代理时遇到问题。 我的 nginx.conf 是默认的(没有对其进行任何更改),我的站点可用配置是: upstream backend_hosts { se
我在 projectlocker(免费 svn 主机)上有一个帐户,但我不知道如何将我的项目文件上传到它。 我在我的仪表板中找不到任何选项。 我在我的电脑上使用tortoiseSvn,那么如何上传文件
设置batchSize = 1有意义吗?如果我想一次处理一个文件? 尝试过batchSize = 1000和batchSize = 1 - 似乎具有相同的效果 { "version": "2.0"
我只想知道.. docker中现在有任何可用的工具吗?我已经阅读了Docker中有关多主机功能的一些文档,例如, Docker群 Docker服务(带有副本) 我也知道群模式下的volume问题,容器
我想将文件从 Docker 的容器挂载到我的 docker 主机。 数据卷不是我的解决方案,因为它们是从 docker 主机到 docker 容器的装载,我需要相反的方法。 谢谢 最佳答案 当 doc
我是新手。我无法正确理解RMI。互联网上有大量教程,但据我所知,它们都是针对本地主机的。服务器和客户端都运行在同一台机器上。 我想在任何计算机上运行客户端,并且主机将位于一台计算机上,让我们考虑IP
我无法从客户端“A”SSH 到服务器“B”(但我可以从同一子网上的许多其他 ssh 客户端而不是“A”——所有都是 *nux 机器) serverA>ssh -v -p 端口用户@serverB Op
设置batchSize = 1有意义吗?如果我想一次处理一个文件? 尝试过batchSize = 1000和batchSize = 1 - 似乎具有相同的效果 { "version": "2.0"
由于我不是天生的编码员,请多多包涵。 这是我尝试使用HAproxy来实现的目标,但是经过数小时的检查后,我无法以某种方式使其工作。 从 domain.com/alpha domain.com/beta
我正在使用 tomcat 运行 Java Web 应用程序,通过电子邮件将生成的报告发送给用户。我可以发送电子邮件,但几个小时后服务器停止发送电子邮件,并出现以下错误。 javax.mail.Mess
我是一名优秀的程序员,十分优秀!