Not able to Connect database by remote connection (used to connect before 3-4 days)

Rohit Karadkar

New Member
Messages
6
Reaction score
0
Points
1
I use to connect database by "absolut.x10hosting.com" from MySql workbench
and It used to work fine, i've also added host ip for remote connection.

x10 Error.PNG
but now it is not working. please help me with solution.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
If it was working, it was a temporary configuration error that allowed it to work. Remote MySQL connections are not allowed on Free Hosting (inbound or outbound); the MySQL server is only supposed to be accessible as "localhost".
 

webjusti

New Member
Messages
13
Reaction score
0
Points
1
Greetings ,

I am trying to include "wp-config.php" so that I can have access to the database by providing the root path to it in a line like this in a file that resides within the WP system:
<?php
session_start();
include 'http://localhost/home/webjusti/ontariofamilylawformsfiller/wp-config.php';

However it does not give me access to database. Does any one know how to include wp-config.php to my home directory-localhost if it says at the control panel that my home directory is /home/webjusti. Example: include 'http://localhost/home/webjusti/ontariofamilylawformsfiller/wp-config.php';
 

webjusti

New Member
Messages
13
Reaction score
0
Points
1
Greetings ,

I am trying to include "wp-config.php" so that I can have access to the database by providing the root path to it in a line like this in a file that resides within the WP system:
< ?php
session_start();
include 'http://localhost/home/webjusti/ontariofamilylawformsfiller/wp-config.php';

However it does not give me access to database. Does any one know how to include wp-config.php to my home directory-localhost if it says at the control panel that my home directory is /home/webjusti. Example: include 'http://localhost/home/webjusti/ontariofamilylawformsfiller/wp-config.php';
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Please don't post new questions into existing threads.

Nothing "above" your document root (public_html or www) is accessible via HTTP; you need to use the filesystem on the server. (On a general note, including anything local via URIs is a bad idea; it invokes an unnecessary loop-back and will probably return the results of running the file, assuming that the file has a .php extension. Oh, and it's usually a good idea to use require or require_once rather than include for something upon which the rest of the page depends. If an include goes missing, you won't notice until you try to use it, which can result in some pretty nasty and confusing error messages going out to the user (or quickly filling your error log file). When a require goes missing, you get an immediate error telling you exacctly what the problem is.)

Your document root (/home/webjusti/public_html) is accessible using $_SERVER['DOCUMENT_ROOT']. To get from there to your user home directory, use the dot-dot directory, then work downward from there if needed. So:

PHP:
require_once $_SERVER['DOCUMENT_ROOT'] . '/../wp-config.php';
 

webjusti

New Member
Messages
13
Reaction score
0
Points
1
Thank you essellar. I understood everything you said. I wasn't sure but I thought now that the thread is started here then I'm going to finish it here. I changed from include to: require_once $_SERVER['DOCUMENT_ROOT'] . '/../wp-config.php'; and it works fine but only on servers that are not localhost unlike webjustice.x10.mx . I have the same website in another hosting that does not use localhost. webjustice.t15.org they use mysql.freehostingnoads.net for MySQL host. My main objective however is to be able to use the localhost of XAMPPLITE ENVIROMENT (DESKTOP SERVER APP FOR CREATING A LOCAL ENVIROMENT OF WORDPRESS.) Or if you are no t familiar with XAMPPLITE to at least be able to use it on localhost of webjustice.x10.mx Thanks in advance again . Note: usually when I do something wrong with the require_once I get an error on the page that points to the line number of the error. But in the localhost it wont even give me any errors or parse the information at all.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
It works just fine with "localhost" as the database server (both on various local stacks, like XAMPP and WampServer, as well as on x10Hosting servers). Are you sure that wp-config.php lives where you think it does?
 

webjusti

New Member
Messages
13
Reaction score
0
Points
1
Hi, Yes I am sure that the wp-config.php lives where it does. The website in question is : http://webjustice.x10.mx/ontariofamilylawformsfiller/ you can logging here http://webjustice.x10.mx/ontariofamilylawformsfiller/wp-admin I created an account for you the user=guest and the pass=guest . The page that contains the information that I need parsing is located here http://webjustice.x10.mx/ontariofamilylawformsfiller/forms/FLR-08-Oct12-EN-fil.htm When I tested the require_once $_SERVER['DOCUMENT_ROOT'] . '/ontariofamilylawformsfillerwp-config.php'; on a different server with mysql.freehostingnoads for MySQL host worked fine this is the website: http://webjustice.t15.org/ontariofamilylawformsfiller/ and the page that has the code in question is here: http://webjustice.t15.org/ontariofamilylawformsfiller/forms/FLR-08-Oct12-EN-fil.htm Notice how http://webjustice.x10.mx/ontariofamilylawformsfiller/forms/FLR-08-Oct12-EN-fil.htm does NOT parse.


Thanks again Hope we can do this thing!!
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Seeing the page isn't the same ting as seeing the code. I can see parse errors (it appears that the PHP tags are being closed prematurely), but there's absolutely no way for me to tell what the real problem is. Please not that this may have little to do with the include, and a LOT to do with different PHP versions/settings.

HANG ON A MINUTE...

You're issuing the PHP. And you're doing that because you're using .htm as the page's file extension. Only pages that use .php as a file extension are parsed and executed as PHP by default. If you want to run PHP on pages having different file extensions, you need to set that in your .htaccess file.
 
Last edited:
Top