Doing wordpress plugin development, I am creating a table (while installing the plugin) with the following string:

$sql = "CREATE TABLE (query skipped)..."; /*someting*/

For example: I have this

register_activation_hook( __FILE__, 'my_plugin_install' );
function my_plugin_install(){

$sql = "CREATE TABLE (query skipped)..."; /*someting*/
echo $sql;

The problem is there is some error with this query and and I want to see the output of $sql using php.

But the above code doesn't echo anything when plugin is installed. Any way to see the ouput?

function my_plugin_install(){

   global $wpdb, $current_user;;

   //getting the musician/user rating keys
    global $k11, $k12, $k13, $k14, $k21, $k22, $k23, $k24;


   $fabulous_profile_version = "2.0";

   //mid= music user id
   //uid = general user id
   //creating the ratings table
   $sql = "CREATE TABLE $fabprofile_table_name (

  mid tinyint(9) NOT NULL,

  uid tinyint(9) NOT NULL,

  $k11 tinyint(1) NOT NULL, $k12 tinyint(1) NOT NULL,$k13 tinyint(1) NOT NULL, $k14 tinyint(1) NOT NULL,

  $k21 tinyint(1) NOT NULL, $k22 tinyint(1) NOT NULL, $k23 tinyint(1) NOT NULL, $k24 tinyint(1) NOT NULL


   require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

   dbDelta( $sql );
    echo $sql;

You could insert a


to output the errors in your query.

Also you need to input that sql into


did you miss that?

  • I am running the $sql query with this: dbDelta( $sql ); It doesn't help :(.. – manojadams Jul 3 '14 at 5:49
  • No output with the show_errors()? Also the debug is set to true right? – Armin Braun Jul 3 '14 at 5:51
  • nope, I don't see any output. It just shows The plugin generated ** characters of unexpected output during activation. Is there any way to see that unexpectedd output? – manojadams Jul 3 '14 at 5:53
  • Did you put a global $wpdb; before your query? And also, did you include wp-admin/includes/upgrade.php ? – Armin Braun Jul 3 '14 at 5:55
  • yes,let me show youy – manojadams Jul 3 '14 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.