I am working on a plugin. I make a query on "register_activation_hook". When I activate the plugin the Query work perfectly, but I get an error
The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
What is the issue? I don't get it.
Here is my code:
function customtaxorder_init() {
global $wpdb;
$init_query = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
if ($init_query == 0) { $wpdb->query("ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT '0'"); }
// For Previous Users Product Images
$prefix = $wpdb->prefix;
$postSql = "SELECT DISTINCT post_id
FROM ".$prefix."postmeta As meta
Inner Join ".$prefix."posts As post
On post.ID = meta.post_id
Where post_type = 'wpcproduct'
And post_status = 'publish'
And meta_key Like '%product_img%'";
$postQry = mysql_query($postSql);
while($postRow = mysql_fetch_array($postQry)){
$post_id = $postRow['post_id'];
$meta_key = "product_images";
$sql = "Select post.*, meta.*
From ".$prefix."posts As post
Inner Join ".$prefix."postmeta As meta
On post.ID = meta.post_id
Where post_type = 'wpcproduct'
And post_status = 'publish'
And meta_key Like '%product_img%'
And post_id = ".$post_id;
$qry = mysql_query($sql);
$prod_key = array();
$prod_value = array();
$a = 0;
while($row = mysql_fetch_array($qry)){
$product_img = $row['meta_key'];
$product_img = preg_replace("([0-9]+)", "", $product_img);
$response[$a] = $row['meta_key'];
$response[$a] = $row['meta_value'];
$data[$a][$product_img] = $response[$a];
$a = $a + 1;
}
//print_r($data);
$data_serialize = serialize($data);
$insert_images = "Insert Into ".$prefix."postmeta(post_id,meta_key,meta_value) Value('$post_id','$meta_key','$data_serialize')";
mysql_query($insert_images);
}
// Delete All product_img1,product_img2,product_img3
mysql_query("Delete From ".$prefix."postmeta Where meta_key IN ('product_img1','product_img2','product_img3')");
// Update All product_price to Product Price
$support_sql = "Select * From ".$prefix."postmeta Where meta_key Like '%product_price%'";
$support_qry = mysql_query($support_sql);
while($support_arr = mysql_fetch_array($support_qry)){
$supportMetaID = $support_arr['post_id'];
$supportMetaPrice = $support_arr['meta_key'];
$price_split = explode("_", $supportMetaPrice);
$supportMetaPrice = $price_split[0]." ".$price_split[1];
$supportMetaPrice = ucwords($supportMetaPrice);
$update_price = "Update ".$prefix."postmeta
Set meta_key = '$supportMetaPrice'
Where post_id = $supportMetaID
And meta_key Like '%product_price%'";
mysql_query($update_price);
}
}
register_activation_hook(__FILE__, 'customtaxorder_init');
Any idea?