Jump to content

connecting to mysql database(either remote or local) from php application


thosecars82

Recommended Posts

Hello people

does anyone have any idea to test a php application using database first in local and afterwards in the remote server?

What i mean is, does anyone know how to do it without having to change the code used to get the connection to the database.

My code to connect to the database looks like this:

//$miconexion->conectar("jorlal8_nueva", "mysql4.freehostia.com", "jorlal8_nueva", "******");//remote

$miconexion->conectar("jorlal8_nueva", "localhost", "jorlal8_nueva", "******");//local

Each time i want to test on remote I have to comment the line to connect to mysql in localhost so that I can be testing at the remote mysql database which in my case is in freehostia. But if i want to test later at localhost i'll have to change the code again.

Does anybody knows how to do this?

Someone told me that he used application variables to know whether the code was running local or not. Besides he told me another posibility which was using xml tags to distinguish between debugging and normal run of the application. Nevertheless, I am still very lost.

Please I would appreciate any help about this.

Thank you

set some variables up top

 

$user = "";
$password = "";
$host = "";
$db = "";

$miconexion->conectar($user, $host, $db, $password);

 

Now all you have to do is change the variables up top. I hope I got the order correct

 

Ray

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.