来帮偶看下这个PHP代码有什么问题?
情况如下:mysql.func.php 是Mysql类文件,其中有一个错误信息显示函数msg
因为我想学习用定界符来输出数据,所以使用了
print <<<EOT
..................
EOT;
形式来输出信息
而其他比如连接数据库呀什么的,如果出错就调用这个错误信息显示函数显示
my.php是测试信息显示函数的文件
内容就是加载类文件,然后连接数据库
但是我现在测试的时候,只会显示一片空白,不知道为什么?
希望各位帮忙看下~~
代码我打包了,如果不愿意下的,等下我直接贴上来 My.php文件代码:
<?php
require "./mysql.func.php";
$m = new Mysql;
$error = "dddddddddd";
$m->connect();
$m->msg("fdsjklfjdsklfjdskl");
?>
mysql.func.php文件代码:
<?PHP
class Mysql {
var $dbhost = "localhost";
var $dbuser = "dddddd";
var $dbpass = "";
var $dbname = "easynovel";
var $link_id;
var $result;
var $record;
var $rows;
/** 返回出错信息 **/
function error() {
return mysql_error($this->link_id);
}
/** 连接数据库 **/
function connect() {
global $pconnect;
if(!$pconnect) {
if(!$this->link_id = @mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass)) {
$this->msg("建立数据永久连接出错");
}
} else {
if(!$this->link_id = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpass)) {
$this->msg("建立数据库连接出错");
}
}
return $this->link_id;
}
/** 错误信息显示 **/
function msg($msg) {
print <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>程序运行出错</title>
<script type="text/javascript">
function Show(divid){
if(navigator.appName=="Microsoft Internet Explorer") document.getElementById(divid).filters.revealTrans.apply();
document.getElementById(divid).style.visibility="visible";
if(navigator.appName=="Microsoft Internet Explorer") document.getElementById(divid).filters.revealTrans.play();
}
function Hide(divid){
if(navigator.appName=="Microsoft Internet Explorer") document.getElementById(divid).filters.revealTrans.apply();
document.getElementById(divid).style.visibility="hidden";
if(navigator.appName=="Microsoft Internet Explorer") document.getElementById(divid).filters.revealTrans.play();
}
</script>
<style type="text/css">
body {
margin: 0;
padding: 0;
background-color: White;
display: block;
border: 0;
font-size: 12px;
font-family: 宋体;
color: Black;
background-color: White;
}
#msgboard {
filter: revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5);
position: absolute;
left: 210px;
top: 150px;
width: 360px;
height: 172px !important;
height: 169px;
z-index: 1;
visibility: hidden;
border: 1px solid #5296FF;
}
#msgboard div {
margin: 1px;
}
#msgboard div#title {
background: #8DACE9;
color: #DEEEF3;
font-weight: bold;
text-align: center;
line-height: 20px;
border: 1px solid #5296FF;
}
#msgboard div#content {
background: #EBF3E6;
line-height: 30px;
border: 1px solid #5296FF;
height: 145px;
}
</style>
</head>
<body onload="Show('msgboard');">
<div id="msgboard">
<div id="title">$msg</div>
<div id="content">
<div style="padding-left: 20px;"><br />$this->error()<br /></div>
<div><ul><li><a href="../index.php" target="_top">点击这里返回首页</a></li></ul></div>
</div>
</div>
</body>
</html>
EOT;
}
}
?> 伤心MM的作品
大家帮帮忙啊 数了花括号,看了代码
似乎是哪个func有错误
但是空间没有显错误代码
看来是你写错了
回复 #5 破晓 的帖子
程序员来了我不会的........ PHP,这几天正跟我那大虫师傅学着的.....还不到可以帮人家看哪错的地步的 你看下源代码是否有内容,有的话抛个GBK的header头出来 祝福以下朋友:(排名不分先后)
JG的:xinke,vbvs,esank,kokgog,鬼仔,xfsoho,姜运涛,大虫,oyido,linxicn,kelyhao ==
偶MJ:风,白
原快手的:鸟,无,md,weew==
在2007里,事业如日中天,心情阳光灿烂,工资地覆天翻,未来风光无限,爱情浪漫依然,快乐游戏人间 祝福以下朋友:(排名不分先后)
JG的:xinke,vbvs,esank,kokgog,鬼仔,xfsoho,姜运涛,大虫,oyido,linxicn,kelyhao ==
偶MJ:风,白
原快手的:鸟,无,md,weew==
在2007里,事业如日中天,心情阳光灿烂,工资地覆天翻,未来风光无限,爱情浪漫依然,快乐游戏人间