Title: database inittialization for a plugin
Last modified: August 19, 2016

---

# database inittialization for a plugin

 *  [sultanos](https://wordpress.org/support/users/sultanos/)
 * (@sultanos)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/database-inittialization-for-a-plugin/)
 * hello folks, i am almost new to the vast PHP programming world , and i have some
   concepts that i misundestand…
 * here is my code
 *     ```
       <?php
       recojerfechas();
       $action = checkGet('action','');
   
       switch($action)
           {
   
               case "pintarfechas":
                   recojerfechas();
               break;
           }
   
       function recojerfechas ()
       {
           global $wpdb;
           $table_name     = $wpdb -> prefix ."temporada" ;
           $query          = "SELECT * FROM $table_name;";
           $result         =  $wpdb -> query($query);
               while ($datostemporada = mysql_fetch_row($result))
                       {
                           $idfila = $datostemporada[0];
                           global $wpdb;
                           $table_name = $wpdb -> prefix ."tarifas";
                           $sql= " SELECT * FROM $table_name WHERE id_tarifa = $datostemporada[4]";
                           $resulta    = mysql_query($sql);
                           $datostarifaaplicada = mysql_fetch_row($resulta);
                       echo "[$datostemporada[2],$datostemporada[3],$datostarifaaplicada[3]]";
                       }
       }
       ?>
       ```
   
 * and this are my errors
    `Notice: Trying to get property of non-object in /usr/
   local/pem/vhosts/118777/webspace/httpdocs/wp-content/plugins/reservations/pintor_de_rangos.
   php on line 16 Fatal error: Call to a member function query() on a non-object
   in /usr/local/pem/vhosts/118777/webspace/httpdocs/wp-content/plugins/reservations/
   pintor_de_rangos.php on line 18`
 * Yes, i am calling this file directly from my Navigator… .You all might say that—
   What is doing a guy that doesnt know how to instanciate an object , making a 
   plugin ? well i am trying to learn….
    What a heck is an object , why at my main
   plugin page works and not here…. i wanted to create more than one page, please
   dont refer me to the codex i come from there , i even copy pasted examples but
   i always get the same error , it seems i need another file (include something)
   or that i need to instaciate an object , which honestly i dont know what it means…
   Thanks for reading till here.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/database-inittialization-for-a-plugin/#post-1338277)
 * If you have a non-native database in your WordPress database then you should 
   be able to access that database using [wpdb](http://codex.wordpress.org/wpdb).
 * But [Creating_Tables_with_Plugins](http://codex.wordpress.org/Creating_Tables_with_Plugins)
   also has some information that may help you.
 *  Thread Starter [sultanos](https://wordpress.org/support/users/sultanos/)
 * (@sultanos)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/database-inittialization-for-a-plugin/#post-1338320)
 * Thanks for answering , i did follow the creating tables with plugin tutorial 
   and i do have my tables inside the wordpress database, but , i still get this
   error, it seems that althought i declare the global $wpdb;
    the object to which
   should be related isnt loading at all, i suspect i am missing a kind of include
   in which the wpdb library class is loaded…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘database inittialization for a plugin’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [sultanos](https://wordpress.org/support/users/sultanos/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/database-inittialization-for-a-plugin/#post-1338320)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
