• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RESOLVED Snippet for connecting to extern Database stopped working / Version 2.1.9

Status
Not open for further replies.

knubew

New member
Messages
2
Likes
0
Points
1
#1
Hello,

my snippet for connecting to an extern Database stopped working. My DB-Config file (db-config.php) is saved in the Wordpress root directory (where also the wp-config.php is saved). In the snipped my "db-config.php" is included via: require_once("db-config.php").

Code:
ERROR-Warning

Warning: require_once(db-config.php): failed to open stream: No such file or directory in /var/www/vhosts/mydomain.de/httpdocs/wp-content/plugins/insert-php/includes/shortcodes/shortcode-php.php(45) : eval()'d code on line 2

Fatal error: require_once(): Failed opening required 'db-config.php' (include_path='.:/opt/plesk/php/7.2/share/pear') in /var/www/vhosts/mydomain.de/httpdocs/wp-content/plugins/insert-php/includes/shortcodes/shortcode-php.php(45) : eval()'d code on line 2
Now I have to use the full server file path to "db-config.php" in the require_once statement.
Is that so wanted?

Best knubew
 

Kirill

Support team
Messages
82
Likes
4
Points
8
#2
Hello

When using require, it is advisable to specify the full file path.
Otherwise, the file will be searched somewhere in the folders of plugin/wordpress.

example:
require_once $_SERVER["DOCUMENT_ROOT"]."/db-config.php";

Best regards
 
Status
Not open for further replies.