Wampserver Upgrading issue

810 views Asked by At

I recently updated my wampserver 2.0 to wampserver 2.5.

And while i am running the php smarty code i am getting this error.

"Fatal error: Class 'DB' not found in 
     C:\wamp\www\livehrm.new\product\common.php on line 63" 

I think it might be a pear issue of old wampserver.

Please help me

//session_start(); 
require_once 'DB.php'; 
$dbHost = $dbconfig['db_hostname']; 
$dsn1[0] = array('type'=>'DB', 'dsnstuff'=>"mysql://$dbUser:$dbPassword@localhost/$dbName"); $dbdsn = "mysql://$dbUser:$dbPassword@$dbHost/$dbName"; 
$db = DB::connect($dbdsn); 
if (DB::isError($db)) { 
   die ($db->getMessage()); 
}
?>
2

There are 2 answers

2
RiggsFolly On

Its not the prefered solution, but this should get you working again.

I strongly recommend that you do in fact convert your code from using the mysql_* extension ot use either the mysqli_* or PDO instead as eventually this approach will not work as the developers of PHP will actually no longer provide the mysql_* extension.

But you can remove the warning messages by changing your php.ini configuration like this :-

Edit php.ini

Find this line

error_reporting = E_ALL

and change it to

error_reporting = E_ALL & ~E_DEPRECATED

Or you can just add this PHP code at the top of your db.phpscript if you dont have access to your php.ini file

error_reporting( E_ALL ^ E_DEPRECATED );

If you are using Virtual Hosts you can actually add this to the specific VH for the site that is still using the old mysql_* extension therefore not affecting other site you may be developing/maintaining

Unfortunately in a VH definition you have to use an integer value.

<VirtualHost....>
   . . .

   php_value error_reporting 24575
</VirtualHost>
9
DJ MHA On

MySQL extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used. Ref: http://php.net/manual/en/function.mysql-select-db.php

Update your DB.php with following code

<?php
$con = mysqli_connect("localhost","root","");
$db="livehrm";

if (!$con)
{
    die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con, $db) or die ("Database connection error:\n" . mysqli_error($con)); 

?>

There is not Class found in you provided code of file DB.php. I will update my answer when you send class code of DB