?
Solved

MDB2 problem in PHP

Posted on 2009-04-25
2
Medium Priority
?
1,042 Views
Last Modified: 2013-12-12
Hi,

I am using PEAR's MDB2 and I am faced with the following error.
Fatal error: Cannot redeclare class MDB2_Error in
/usr/share/php5/PEAR/MDB2.php on line 977

This happens in the login page if the query fails (if they user credentials are wrong). Probably happens in other places if wrong input is passed and the query fails.

It is not installation dependant, I have tested it in many setups. It is not PEAR dependant, I have created my own pear directory and changed the include path accordingly.

I need to make this error message dissapear and let the script die in a more legant way. Also, I would like to understand why it happens.

Thank you very much.
0
Comment
Question by:webspirit
2 Comments
 
LVL 6

Accepted Solution

by:
basic612 earned 1000 total points
ID: 24234100
My guess would be that somewhere in your application there is a class definition for MDB2_Error.

Search your whole application folder recursively for the text string MDB2_Error

for Linux / OS X you can cd to the directory that your application resides in and:

grep -R MDB2_Error ./

For Windows I like to user notepad++ for my coding (or Zend Studio) and you can use the recursive find functions in there.

If you find MDB2_Error being declared in any of your scripts you can probably comment out the section that declares it, or otherwise wrap the class definition in a check like this:

if (!class_exists('MDB2_Error')) {
    // define MDB2_Error class here
}

To stop the error messages showing you would have to disable error display:

http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

display_errors should be turned off for any production sites at any rate.

To advise in more detail I'd have to see the actual script in question. Is it a standard / open source script?
0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 1000 total points
ID: 24234991
Your code probably includes a line something like ...

include 'MDB2_Error';

or

include 'MDB2_Error';


This will probably already be included by PEAR. Remove the line. The exact value will depend upon the proper name of the file.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question