I used PDT, a PHP version of eclipse, to debug my issues. I had to add the Wordpress files to the PHP include of my project, then I could run my script in debug mode.
My issues were multiple. The syntax error was an extra closing parenthesis (doh!).
More importantly, $wpdb->query did not work as I expected. If the query fails, it returns false. If the query succeeds, it returns the number of rows acted on (rows selected, or inserted, or deleted, etc...). Was more confusing to me, but makes sense I guess, is that $wpdb->print_error() will still return a valid String on success, complete with an error message (but no error). So my insert was succeeding, but I thought I had an error, causing my error logic to execute.
All better now. I now have my first working plugin!
My issues were multiple. The syntax error was an extra closing parenthesis (doh!).
More importantly, $wpdb->query did not work as I expected. If the query fails, it returns false. If the query succeeds, it returns the number of rows acted on (rows selected, or inserted, or deleted, etc...). Was more confusing to me, but makes sense I guess, is that $wpdb->print_error() will still return a valid String on success, complete with an error message (but no error). So my insert was succeeding, but I thought I had an error, causing my error logic to execute.
All better now. I now have my first working plugin!
Comments