Hot answers tagged

5

You should be using the wpdb class for all your own queries. All core queries also use wpdb. See wpdb Show and Hide SQL Errors <?php $wpdb->show_errors(); ?> <?php $wpdb->hide_errors(); ?> You can also print the error (if any) generated by the most recent query with print_error. <?php $wpdb->print_error(); ?> Also see ...


4

I wouldn't use that hook. Here's why Try something like this using admin_notices. function wpsites_admin_notice() { $screen = get_current_screen(); if( 'post' == $screen->post_type && 'edit' == $screen->base ){ ?> <div class="error"> <p><?php _e( 'Updated Demo Message!', 'wpsites' ); ?></p> </div> <?...


4

It's best to just log errors to the server and then use bash or a server script that supports email and error analysis (instead of PHP). There are lots of log file tools out there, simple ones like Logwatch, Swatch, Octopussy, or more complex ones like Nagios. For errors which are triggered using WP_Error you can write an email alert or log function right ...


3

I think it's impossible to give a definitive answer here, because choiches like this are personal preference. Consider that what follows is my approach, and I have no presumption it is the right one. What I can say for sure is that you should avoid your third option: Just return null/false This is bad under different aspect: return type ...


3

335 is not an error message or code, it is the new post's ID that is retuned, so in short, the new post you have inserted was given the ID of 335 UPDATE wp_insert_post() already returns a WP_Error object on failure, so simply var_dump( $result ); would give you a specific error message on failure or the new post ID on success


2

This is actual mail server trouble, where email cannot be sent. This link will useful. http://angstrey.com/index.php/2009/04/22/how-to-send-e-mail-with-wordpress-from-godaddy-windows-hosting/


2

Fatal errors point to bad syntax, or bad naming conventions. WordPress does a good job of not activating plugins that throw fatal errors. However, once a plugin is activated, all bets are off. If you've created a function or a class, it's best to follow good naming conventions and namespace properly. For example, a function called post_extras() would not be ...


2

If you will write inside the console of your browser, then use one of a lot of helpers or use a small custom function in php. The follow function is easy to use and log inside the console of the browser. if ( ! function_exists( 'debug_to_console' ) ) { /** * Simple helper to debug to the console * * @param object, array, string $data ...


2

if ( is_wp_error($term_id) ) { // oops WP_Error obj returned, so the term existed prior // echo $term_id->get_error_message(); } See if that works for you.


2

This works fine for me as db-error.php in wp-content: Delete the mailer block if you don't want it <?php header('HTTP/1.1 503 Service Temporarily Unavailable'); ?> <?php $to = "me@mysite.com"; $subject = "My Database is down"; $message = "My Database is down"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=...


2

Why not just use the browser's "developer" tool to display the errors and the code that caused the error? I know for a fact that IE, Firefox and Safari each have developer tools available (I use them all the time) - I don't know about other browser's capabilities.


2

The output that you posted above is expected behaviour for $wpdb->print_error() if the following is true - You are running a single site, not multisite $wpdb->suppress_errors is set to false $wpdb->show_errors is set to false From the looks of your code, you meet all those conditions. Note also that, unless you have turned them off previously, $...


1

It looks like your $categories is an empty array. To solve this always check if the array is empty or not. In line 117 add code to check if array is empty <?php if( !empty( $categories ) ){ ?> and in line number 167 replace <?php } ?> with <?php } } ?> If you want to permanently remove any error or warning message you can use the ...


1

add_settings_error( 'myUniqueIdentifyer', esc_attr( 'settings_updated' ), $message, $type ); Check http://codex.wordpress.org/Function_Reference/add_settings_error


1

This is how I've handled passing messages back to the user before: within your current function, set a transient with your message: set_transient( 'admin_notice', 'Please put down your weapon. You have 20 seconds to comply.' ); Then add a new hooked function: function admin_notices() { $notice = get_transient( 'admin_notice' ); if ( $notice ) { ...


1

You've already got a check for $_POST == empty. **if (!empty($_POST)){ $pfs = pfs_submit($_POST,$_FILES); echo json_encode($pfs); //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($pfs, true)."\n"; wp_redirect("http://domda.se/tack/"); exit; } else { /* TODO: translate following */ _e('Den här sidan hade du inte behövt se, något ...


1

Just did a quick search to see if JavaScript has a global error handling function which you could use and found window.onerror. So I haven't looked any further into it to see if it's well supported, but presumably you could use the window.onerror function to send an ajax request to php which could send page,browser, probably failed script info etc. then use ...



Only top voted, non community-wiki answers of a minimum length are eligible