我遇到了问题,我将项目从 dev 下载到我的本地,虽然它在 dev 上运行良好,但在本地,它告诉我以下错误 Fatal error: Class 'DB' not found in F:\xampp\htdocs\第 9 行的 timesheet\index.php 我的 index.php 是
<?php
session_start();
error_reporting(1);
include_once('classes/db.php');
include_once('classes/functions.php');
//==========================================
$dbFun=new DB();
$dbFun->ConnectToDb();
$incFun= new Functions();
//==========================================
if(isset($_GET['file'])){
$file = $_GET['file'];
}
else if(isset($_POST['file'])){
$file = $_POST['file'];
}
else{
$file = "login.php";
}
?>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>::Administration::</title>
<? if(($file != "login.php") && ($_SESSION['sid'] != "")){?>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="js/CalendarPopup.js" type="text/javascript" language="JavaScript"></script>
<script type="text/javascript" src="js/sortable.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script>
</head>
<body>
<table width="100%" height="90%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#1F5F69">
<tr>
<td height="36" colspan="3" valign="top">
<table width="100%" height="150" border="0" cellpadding="0" cellspacing="0" style=" background:url(images/topbg.jpg); background-repeat: repeat-x;">
<tr>
<td width="30%" rowspan="2" align="left" valign="top"><img src="images/logo_quality_web_programmer.jpg" alt="Miami Truck Guide" width="351" height="151" /></td>
<td width="70%" height="76" align="right" valign="top"><table width="500" border="0">
<tr>
<td align="right" style="color:#FFFFFF;">Welcome <? echo $_SESSION['sid'];?> | <a href="?file=logout.php" style="color:#FFFFFF;">Logout</a> | Search</td>
<td width="23"> </td>
</tr>
<tr>
<td align="right" valign="top"><span id="top-search"><form id="form1" name="form1" method="post" action=""><input name="search" type="text" id="search" />
<input type="image" src="images/search.png" name="Submit" value="Submit" /></form></span></td>
<td> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td width="213" rowspan="2" valign="top" style=" background:url(images/leftbg.jpg); background-repeat: repeat-x;">
<? if($_SESSION['type'] == "Administrator"){
include("admin_nav.php");
} else{
include("emp_nav.php");
}?></td>
<td width="11" rowspan="2" valign="top"> </td>
<td width="990" height="10" valign="top"></td>
</tr>
<tr>
<td valign="top"><? include($file);?></td>
</tr>
</table>
<? } else { include("login.php");}?>
<script type="text/javascript">
$(document).ready(function(){
//$('#pid').click(function(){
$("select").change(function(){
//alert("asma");
var puid = $("#pid").val();
document.getElementById(puid).style.display = 'block';
});
$("#button").click(function(){
var frm = document.getElementById("leftform");
frm.submit();
});
});
</script>
</body></html>`
我的 db.php 是
<?
//include("lang.inc.php");
//========================================
class Variables{ // database variables defined in the class
var $dbServer;
var $dbUser ;
var $dbPass ;
var $dbName ;
function Variables(){
$this->dbServer = "localhost";
$this->dbUser = "root";
$this->dbPass = "";
$this->dbName = "timesheet";
}
}
//+----------------------------------------+
class DB { // database class contains the function
var $dbase;
var $connection;
function ConnectToDb()
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.
$vari=new Variables();
$this->connection = mysql_connect($vari->dbServer, $vari->dbUser, $vari->dbPass)
or die("Could not connect : " . @mysql_error());
$this->dbase = mysql_select_db($vari->dbName, $this->connection);
if(!$this->connection || !$this->dbase){
return false;
}
else{
return true;
}
}
//==============================
function selectMultiRecords($query)
{
if((@$result = mysql_query ($query))==FALSE)
{
if (DEBUG=="True")
{
echo mysqlMessage($query);
}
}
else
{
$count = 0;
$data = array();
while ( $row = mysql_fetch_array($result))
{
$data[$count] = $row;
$count++;
//echo "<br>";
}
return $data;
}
}
//===============================
function selectFrom($query)
{
if((@$result = mysql_query ($query))==FALSE)
{
if (DEBUG=="True")
{
echo mysqlMessage($query);
}
}
else
{
if ($check=mysql_fetch_array($result))
{
return $check;
}
return false;
}
}
//==========================
function countRecords($query)
{
$res = mysql_query($query);
$results = mysql_num_rows($res);
return $results;
}
//==============================
function isExist($query) {
if((@$result = mysql_query ($query))==FALSE){
if (DEBUG == "True"){
echo mysqlMessage($query);
}
} else {
if ($check=mysql_fetch_array($result)){//mysql_fetch_array return flase if there are no records
return $check;
}
return false;
}//else
}
function insertInto($query)
{ //echo $Querry_Sql;
if((@$result = mysql_query ($query))==FALSE)
{
if (DEBUG=="True")
{
echo mysqlMessage($query);
}
}
else
{
return true;
}
}
function deleteFrom($query)
{
if((@$result = mysql_query ($query))==FALSE)
{
if (DEBUG=="True")
{
echo mysqlMessage($query);
}
}
else
{
return true;
}
}
//================================
function update($query)
{
if((@$result = mysql_query ($query))==FALSE)
{
if (DEBUG=="True")
{
echo mysqlMessage($query);
}
}
else
{
return true;
}
}
function mysqlMessage($query)
{
echo "<div align='left'><strong><font color='red'>Site Name e r r o r:</font></strong><br>";
echo "Error in your Query: $query<BR>";
echo "<strong><font color='red'>m y s q l g e n e r a t e d e r r o r:</font></strong><BR>";
echo mysql_errno() . " " . mysql_error() . "</div>";
}
//Mail function
function mxmail($to,$subject,$msg, $fromname, $fromemail, $ishtml="true")
{
$headers = "MIME-Version: 1.0\r\n";
if($ishtml=="true")
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
else
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: ".$fromname." <".$fromemail.">\r\n";
@mail($to, $subject, $msg, $headers);
}
}//========end of class
?>