Title: include php script from file
Last modified: August 20, 2016

---

# include php script from file

 *  Resolved [Cubeloop](https://wordpress.org/support/users/cubeloop/)
 * (@cubeloop)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/)
 * Hi,
    I’m a newbie with both WP and PHP and need your help. I’m setting up a blog
   which will use rendered images with the use of a php file. I have downloaded 
   the script from here [http://cube.crider.co.uk/visualcube.php](http://cube.crider.co.uk/visualcube.php)
   which is under GNU licence (free to use) I have uploaded the files into /wp-content/
   themes/twentyeleven/vcube/ I have the “Allow PHP in posts and pages” plugin installed
   and trying to run the script with
 *     ```
       [php debug=1]
       include ('/wp-content/themes/twentyeleven/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
       [/php]
       ```
   
 * What am I doing wrong here?
    I get the following errors
 *     ```
       Warning: include(/wp-content/themes/twentyeleven/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3) [function.include]: failed to open stream: No such file or directory in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
   
       Warning: include() [function.include]: Failed opening '/wp-content/themes/twentyeleven/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3' for inclusion (include_path='.:/usr/local/php5/share/pear') in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
   
       Notice: Undefined variable: res in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php on line 52
       ```
   

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

 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319424)
 * First rather than changing the default theme use a [child theme](http://codex.wordpress.org/Child_Themes)
   as your changes will be lost if The next WordPress upgrade included the theme,
   as the upgrade [deletes the files and re-writes them](http://codex.wordpress.org/FAQ_Troubleshooting?#Why_did_I_lose_custom_changes_to_the_WordPress_Default_Theme_during_the_last_automatic_upgrade.3F).
 * Once you have that sorted then You need the full path!
 * `get_stylesheet_directory_uri()` will find the url for the theme.
 *     ```
       [php debug=0]
       include_once(get_stylesheet_directory_uri() .'/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
       [/php]
       ```
   
 *  Thread Starter [Cubeloop](https://wordpress.org/support/users/cubeloop/)
 * (@cubeloop)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319445)
 * Hi,
    I created a child theme in /wp-content/themes/vcube I created the style.
   css file to contain
 *     ```
       /*
       Theme Name:     Twenty Eleven Child
       Theme URI:      http: //example.com/
       Description:    Child theme for the Twenty Eleven theme
       Author:         Your name here
       Author URI:     http: //example.com/about/
       Template:       twentyeleven
       Version:        0.1.0
       */
   
       @import url("../twentyeleven/style.css");
       ```
   
 * It messes with the parent style (as stated in the child theme link you gave, 
   but I thought as long as I did’nt add anything to the child the parent should
   still be valid via the [@import](https://wordpress.org/support/users/import/)
   url tag. Now the logo is gone for instance…
 * Anyway,
    I use the code you gave me
 *     ```
       [php debug=0]
       include_once(get_stylesheet_directory_uri() .'/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
       [/php]
       ```
   
 * But I now get these errors
 *     ```
       Warning: include_once() [function.include-once]: URL file-access is disabled in the server configuration in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
   
       Warning: include_once(http://cubeloop.com/wp-content/themes/vcube/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3) [function.include-once]: failed to open stream: no suitable wrapper could be found in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
   
       Warning: include_once() [function.include]: Failed opening 'http://cubeloop.com/wp-content/themes/vcube/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3' for inclusion (include_path='.:/usr/local/php5/share/pear') in /home/c/cubeloop/cubeloop/cubeloop.com/www/wp-content/plugins/allow-php-in-posts-and-pages/allowphp.php(50) : eval()'d code on line 2
       ```
   
 * It makes no sense to me
 * /Dennis
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319555)
 * If you want to include the script then do it in the child themes functions.php
   and not in a page or post, includes are ok in the **functions.php**.
 *     ```
       function get_visualcube() {
          if( is_singular() ) {
             include_once(get_stylesheet_directory_uri() .'/vcube/visualcube.php?fmt=gif&size=200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3');
          }
       }
       ```
   
 * In the page call the function?
 *     ```
       [php debug=0]
       get_visualcube();
       [/php]
       ```
   
 * HTH
 * David
 *  Thread Starter [Cubeloop](https://wordpress.org/support/users/cubeloop/)
 * (@cubeloop)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319569)
 * Hi David,
    I’m at work and don’t have access to upload the file to the server
   right now. I will check it later tonight.
 * BUT, I don’t think it will work since the arguments passed to the visualcube.
   php will change for every image I create
    For instance a 3d view of the rubiks
   cube with the moves RUR’ (*) applied to it will look like [http://cube.crider.co.uk/visualcube.php?fmt=gif&size=200&alg=RUR&#8217](http://cube.crider.co.uk/visualcube.php?fmt=gif&size=200&alg=RUR&#8217);
   a top view of the cube were you have to orient the 4 corners and permute the 
   for edges will look like [http://cube.crider.co.uk/visualcube.php?fmt=gif&size=200&view=plan&case=RUR’U’R’U2RUR’UR2U2R’y2&arw=U1U5,U5U1,U3U7,U7U3](http://cube.crider.co.uk/visualcube.php?fmt=gif&size=200&view=plan&case=RUR’U’R’U2RUR’UR2U2R’y2&arw=U1U5,U5U1,U3U7,U7U3)
 * I also think I will have problems with the single quote (‘) in the parameters
   above, but I think that \’ will do the trick?
 * The reason is that I want the script to generate different cases for me as .png
   or .gif instead of spending lot of time photoshop’ing
 * * It’s rubiks cube notation where R is the right face and U is the upper face.
   R is clockwise, R’ is counterclockwise
 *  Thread Starter [Cubeloop](https://wordpress.org/support/users/cubeloop/)
 * (@cubeloop)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319636)
 * Hi,
    the only thing that happens is that function get_visualcube() { if( is_singular()){
   include_once(get_stylesheet_directory_uri() .’/vcube/visualcube.php?fmt=gif&size
   =200&view=plan&case=RURURU2RURUR2U2Ry2&arw=U1U5,U5U1,U3U7,U7U3′); } } is output
   on the top of the screen
 * /Dennis
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319648)
 * It requires database tables and a connebt for the visualcube, not sure if it 
   is for WordPress.
 * I created a test function and passed in arguments, but it is looking for a database
   connection in the visualcube file.
 * I added the localhost database connections then got table errors, so it looks
   like you will need to do some more digging!
 * Here is my code for functions.php
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * HTH
 * David
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319649)
 * HaHa!
    After all that someone has already turned it into a wordpress plugin!
 * [http://www.vanderblonk.com/tools/wordpress-rubik-plugin/](http://www.vanderblonk.com/tools/wordpress-rubik-plugin/)
 * If that works, please mark this one resolved!
 * HTH
 * David
 *  Thread Starter [Cubeloop](https://wordpress.org/support/users/cubeloop/)
 * (@cubeloop)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319698)
 * Hi David,
    figured it out! 🙂
 * I thought like this, the .php file creats an image. Then I inserted the file 
   and parameters within the <img> tag. like
    `<img src="http://www.cubeloop.com/
   vcube/visualcube.php?fmt=png&size=200&view=plan&bg=t&case=RUR'U'R'U2RUR'UR2U2R'y2&
   arw=U1U5,U5U1,U3U7,U7U3"/>`
 * I also moved the file outside WP and deleted the child theme. In the visualcube.
   php file I noticed that it calls for image caching (mysql requests), but since
   my site will not generate many hits (…) I modified the value $ENABLE_CACHE to
   false. Now it works like a charm.
 * I also did try the vanderblonk plugin. It work out of the box! It has not as 
   many options like the other one. I will have to dig deeper of which is best suited
   for me. There is also a third option [http://software.rubikscube.info/icube/](http://software.rubikscube.info/icube/)
   which I have not tried yet
 * Thanks for all the help and effort you have given me, truly appriciated
 * /Dennis

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

The topic ‘include php script from file’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [script](https://wordpress.org/support/topic-tag/script/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [Cubeloop](https://wordpress.org/support/users/cubeloop/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/include-php-script-from-file/#post-2319698)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
