Title: Plugin activation problem
Last modified: August 19, 2016

---

# Plugin activation problem

 *  [ragulka](https://wordpress.org/support/users/ragulka/)
 * (@ragulka)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-activation-problem-2-2/)
 * Hi, I’m having a really frustrating problem. I was developing my plugin (it was
   active all the time) and then I needed to run a function once on the plugin activation
   to do some database queries.
 * I used `register_activation_hook(__FILE__, pt_activate());` as supposed to but
   WP kept giving me an error stating that pt_activate() is already declared and
   it cannot be declared again. After some searching in the web I found out that
   there must be something wrong inside my function.
 * So I removed rehister_activation_hook completely and started deleting lines from
   my function until i was only left with this:
 * `$pt_parentpages = $wpdb->get_results("SELECT ID, post_title, menu_order FROM
   $wpdb->posts WHERE post_type = 'page' AND post_parent = '0' ORDER BY menu_order
   ASC");`
 * And when I try to activate the plugin, it says: Plugin could not be activated
   because it triggered a fatal error.
 * ANd it doesn’t say anything more. And it worked fine ( I didn’t get any fatal
   errors) when the plugin was active while i was developing it and I used the same
   query.
 * When I remove the query, WP activates the plugin.
 * So my question is – what’s wrong? Can I not use $wpdb->query or anything like
   that at all in my plugin?

Viewing 1 replies (of 1 total)

 *  Thread Starter [ragulka](https://wordpress.org/support/users/ragulka/)
 * (@ragulka)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-activation-problem-2-2/#post-1244373)
 * Sorry, my bad. I had a typo in `global $wpdb;`

Viewing 1 replies (of 1 total)

The topic ‘Plugin activation problem’ is closed to new replies.

## Tags

 * [plugin activation](https://wordpress.org/support/topic-tag/plugin-activation/)
 * [queries](https://wordpress.org/support/topic-tag/queries/)
 * [register_activation_hook](https://wordpress.org/support/topic-tag/register_activation_hook/)

 * 1 reply
 * 1 participant
 * Last reply from: [ragulka](https://wordpress.org/support/users/ragulka/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-activation-problem-2-2/#post-1244373)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
