Forum Moderators: coopster

Message Too Old, No Replies

PHP include of mysql login problem

         

akula

7:29 pm on Aug 1, 2008 (gmt 0)

10+ Year Member



I have a mysql db that I want to access from multiple sites. I have the mysql db allowing access to each site's IP and have set up a php include of the connection details and a few other things.

So a site grabs the connection file from the other site and uses that to access the db. (there is more in that file also that makes an include useful otherwise I wouldn't bother).

However, it is not working and I am wondering if I can include a php file containing variables to connect to the db from a remote site?

I can get some text echoed so I know it's reading the file but it doesnt seem to be working and I have the file within <? ?> so it is being parsed.

Any ideas? thanks in advance.

dreamcatcher

6:33 am on Aug 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You probably need to allow access to the remote site. Most servers don`t allow you to connect to another servers database unless you grant that site access. If you use CPanel, click the 'Remote SQL' link and enter the remote servers IP address.

dc

akula

9:28 pm on Aug 2, 2008 (gmt 0)

10+ Year Member



Thanks for the reply.

I have allowed access to the remote site/db. Its reading the remote file but it's not executing the php file.

It will print text in the file but the mysql_connect details don't seem to work because I'm getting connection errors and I am positive the login details are correct.

mrscruff

11:58 am on Aug 4, 2008 (gmt 0)

10+ Year Member



Just two ideas:

1: Have you tryed using <?php ?> instead of <? ?>.

2: If you are using functions, check that the functions exist useing function_exists('function_name') or get_defined_functions().

Could you explain/show the error(s) you are getting?

janharders

12:12 pm on Aug 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>So a site grabs the connection file from the other site and uses that to access the db.

you should _never_ do that. don't expose database information on a public webserver. never ever. anyone could, with a little luck, guess the filename and get your login credentials.

Exactly how does your include-code look?
How does the included file look?
Is the included file a .php, so it will be interpreted on the server it's living on?