i am having a problem, i downloaded the project from dev to my local, though it is running fine on dev but on local, it says me the following error Fatal error: Class 'DB' not found in F:\xampp\htdocs\timesheet\index.php on line 9 my index.php is

    <?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'];?>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="?file=logout.php" style="color:#FFFFFF;">Logout</a>&nbsp;&nbsp;|&nbsp;&nbsp;Search</td>
                <td width="23">&nbsp;</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>&nbsp;</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">&nbsp;</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>`

and my db.php is

<?
    //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 &nbsp;&nbsp;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 &nbsp;g e n e r a t e d &nbsp;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 

?>
Member Avatar for BloccPrince

Try this

        // The name of the php file that contains the connection
        include 'DB.php'; 
        $dbfun = new DBConnection("username", "localhost", "password", "database  name");
        $dbfun->ConnectToDb();

the probelm was because of short tags
i changed

<? to <?php in db.php and it was working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.