Display database error message

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
Ertenal
Forum Members
Forum Members
Posts: 19
Joined: Fri Sep 30, 2011 2:28 pm

Display database error message

Post by Ertenal »

When i create a module, i sometimes write incorrect sql queries. After all, i'm only human :-). But the annoying part is that i won't get a sql error message when that happened. I have to check if the $dbresult variable (result of the Execute function) is false. This is very annoying and time consuming in the debug process.

Is there a way to turn the database error messages on? I have tried to search it here, but could not find an answer.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Display database error message

Post by Wishbone »

Have you tried activating debug mode in config.php? I know it shows the query, but am not sure if it shows the error.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Display database error message

Post by calguy1000 »

Code: Select all

if( !$dbresult ) {
   debug_display($db->sql);
   debug_display($db->ErrorMsg());
}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Ertenal
Forum Members
Forum Members
Posts: 19
Joined: Fri Sep 30, 2011 2:28 pm

Re: Display database error message

Post by Ertenal »

@Wishbone I have tried debug mode; it still throws an error when dbresult = false.

@calguy1000 True, that will work. But since i query alot, i would have to put this code every where. I want to to give me an error message when an error occured, not when i check for errors.
Post Reply

Return to “Developers Discussion”