0

I have xampp and I wrote this code:

    <!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=utf-8" />
<title>pear</title>
</head>

<body>
<?php
require 'DB.php';
$db = DB::connect('mysql://root@localhost/asd');
$query = "select * from asd";
$result = $db->query($query);
 while($raw = $result->fetchRow(DB_FETCHMODE_ASSOC))
 {
 echo $row['1'] , " ";
echo $raw['2'], "<br>";
 }

?>
</body>
</html>

But when I opened the file on localhost it wrote:

Fatal error: Class 'PEAR_Error' not found in C:\xampp\php\pear\DB.php on line 947.

I reinstalled "DB" and checked if pear is installed and everything was ok.

guy
  • 40
  • 7
  • may be help you: http://stackoverflow.com/questions/62658/getting-pear-to-work-on-xampp-apache-mysql-stack-on-windows – Bora Jul 29 '13 at 12:30
  • i have already saw that and this is not the problem and now i have searched in the "DB.PHP" FILE and i didn't found the function or class called "pear_Error" – guy Jul 29 '13 at 12:35

1 Answers1

0

It's not a direct solution, but I suggest you move away from PEAR's DB and switch to PDO. It's very similar to what you're doing now and well-supported since it's a part of PHP.

A good quick-start guide can be found here: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

Ambroos
  • 3,456
  • 20
  • 27
  • thank you very mutch. i did it with "DB" because i am learning from a book and that what they said to do. – guy Jul 29 '13 at 13:44
  • It's a bit dated. PDO is by far the best option at this moment. It's nice since it allows you to use the same PHP code for all database systems, and it's easy to install. Good luck! – Ambroos Jul 29 '13 at 14:19