Take the 2-minute tour ×

Here's my situation: I have a file, homepage.php, that I want to allow my customers to host on their servers. homepage.php needs to somehow get information from my database, but I don't want my customers to have full access to my database. What's the best way to do this and how can I make it work?

I tried to do it by including the line:

require( "http://www.mydomain.com/connect.php" );

in homepage.php but I'm not sure if that's the right way and also, it gives me an error.

share|improve this question
use webservices to expose your data to your customers without giving them complete access to your db –  Jason May 1 '12 at 20:26
add comment

2 Answers

up vote 4 down vote accepted

What error does it give you? Also that won't work because your server parses the PHP and send back the result, rather than including the source code like you want.

Easy solution

Have a read-only account, and give those details out to your customer's pages.

Then they can set up the mysql connection with the IP/exposed port of your mysql server and log-in from there.

Better solution

Have accounts for each customer, so privileges can vary accordingly, otherwise same as above.

Best solution

Expose access via a SOAP service. If you have enough customers and they're developing with you, an API is invaluable.

share|improve this answer
add comment

Without the warning it is hard to troubleshoot the connection issue although I bet it might have something to do with it looking at localhost versus the IP of the machine where the database resides.

The best solution is to have an ini file that has the username and password in it for each individual customer and have the connect.php file look for the ini file on that customers local webserver. You can then configure the priveleges for each account to have only select access to certain tables, or update priveleges to certain users, etc.

Also if your customers will be building their own code around yours, developing a SOAP service might be useful.

share|improve this answer
add comment

Your Answer


