This topic is locked

How to make single project connect to different databases passing database name via URL?

10/9/2014 10:58:48 AM
PHPRunner General questions
G
gonzalosb author

hi,

basically i wan to use one project with different databases (exactly same structure).

i found this on PHPRunner forum TIPS AND TRIKS an i need to change it from PHP to ASP, is any way to do it?

i have MS Access Database
thank you

Q: I have created a script that works, but it is assigned to just one database. I have a number of identical databases on same server, and would like to assign each one when they login. Is there a way to do that? table names are all the same.

A:

Here is an example of how this can be done

  • create a new server database connection in PHPRunner ('Output directory' screen)

    Assuming that you use MySQL, leave all connection parameters intact except database name. Modify the last line according to my example.
    if($_GET["dbname"])

    $_SESSION["dbname"]=$_GET["dbname"];
    $host="localhost";

    $user="root";

    $pwd="";

    $port="";

    $sys_dbname=$_SESSION["dbname"];
  • now you can point users to the URL like this one:

    --http://mywebsite.com/login.php?dbname=database_name_here--