Title: Using a PHP include within PHP-to-Page plugin
Last modified: August 20, 2016

---

# Using a PHP include within PHP-to-Page plugin

 *  [KristofferNord](https://wordpress.org/support/users/kristoffernord/)
 * (@kristoffernord)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/using-a-php-include-within-php-to-page-plugin/)
 * I am using the plugin php-to-page by Bloafer to include php in many of the pages
   on my wordpress site. I would like to include some php code that has an include
   in it and I can’t seem to get it to work.
 * The include is a database connection class to allow me to dynamically populate
   what is on a particular page. I can get it to work if I put it right in the php
   file I’m include using the plugin but I’d like to only have the connection info
   in one place and not in the WordPress folder structure.
 * This is what works in the php file…
 *     ```
       $db = MySqlDatabase::getInstance();
   
       // connect
       try {
           $db->connect('xxxxxx', 'xxxxxx', 'xxxxxx', 'xxxxx');
       }
       catch (Exception $e) {
           die($e->getMessage());
       }
       ```
   
 * This is how I’d like to include it instead …
 * `include(ABSPATH . ‘/ds_2cnx_class.php’);`
 * Any ideas how I can get this to work?

Viewing 1 replies (of 1 total)

 *  [Bloafer](https://wordpress.org/support/users/bloafer/)
 * (@bloafer)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/using-a-php-include-within-php-to-page-plugin/#post-2275607)
 * I would use the internal WP database functions for this, but you can use the 
   plugin to include multiple files, this would probably overcome your issues

Viewing 1 replies (of 1 total)

The topic ‘Using a PHP include within PHP-to-Page plugin’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [Bloafer](https://wordpress.org/support/users/bloafer/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/using-a-php-include-within-php-to-page-plugin/#post-2275607)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
