1

Recently i ordered a webserver, because i needed a mail function to work on a PHP Wordpress plugin. So i moved everything from my localhost to the webserver, but for some reason an include doesn't work anymore.

The file i need to include is in: /domains/brentlobbezoo.nl/public_html/wp-content/plugins/dnhadmin/connectie.php

The website i'm including the page in is in: /domains/brentlobbezoo.nl/public_html/wp-content/plugins/dnhadmin/leden/leden-list.inc.php

The include is made simple:

<?php include ('../connectie.php'); ?>

But that doesn't seem to work. If i move the connectie.php into the same folder as where leden-list.inc.php is in and i change the include to include ('connectie.php'), it suddenly does work.

Is there any way to keep the connectie.php in the folder where it is now, but include it in every page?

Thanks in advance!

P.S. I'm aware of the option to use golbal $wpdb; instead of the connection.php, but then i have to refactor some of my sql queries and i don't have that much time left to finish this project

4
  • use query in $wpdb $sql = "SELECT * FROM wp_reminders WHERE reminder LIKE '$today'"; $result = $wpdb->get_results($sql) or die(mysql_error()); Commented May 27, 2015 at 7:06
  • This is the weirdest error, that could happen, why doesn't it include it from the parent folder? You must have access to it. Commented May 27, 2015 at 7:06
  • Try this: <?php include ('../dnhadmin/connectie.php'); ?> Commented May 27, 2015 at 7:12
  • Thanks for the answers, tried $wpdb real quick, but that didnt seem to work (I'll try that later on a bit more), and @Sagar that didn't work aswell unfortunatly... Very weird error... The include also doesnt give an error if i just type in some random letters Commented May 27, 2015 at 7:16

2 Answers 2

5

Problem is your way. Use this:

<?php include (dirname( __FILE__ ) . '/connectie'); ?>
Sign up to request clarification or add additional context in comments.

Comments

2

It depends on where you are including leden-list.inc.php

You can get the base url of the script file using $basepath =$_SERVER['DOCUMENT_ROOT'];

Now you can use as:

include($basepath."/plugins/dnhadmin/connectie.php");

1 Comment

Thanks a lot man! This worked for me: $basepath =$_SERVER['DOCUMENT_ROOT']; include($basepath."/wp-content/plugins/dnhadmin/connectie.php");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.