Database Connecting on different machines

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
trash80
User
Posts: 2

Database Connecting on different machines

Post by trash80 »

Hi guys,

I got the demo running locally with WAMP quite quickly and found the whole PHPMaker environment quite intuitive.

The litmus test was to get it running on the hosting platform.

Now please correct me if I'm wrong - my understanding was that I could script Database_Connecting to connect to my local MySQL server when running in the local WAMP machine but connect to the hosting provider's MySQL server when running on their box.

Having done that it doesn't run in either so I'm missing something here.

Can anyone point me to the definitive explanation of how this works and how to configure it.

Thank you so much!!!


mobhar
User
Posts: 11905

Post by mobhar »

You may post your code in that Database_Connecting for more discussion. You may hide your actual connection password for security reason in the code you will post.


trash80
User
Posts: 2

Post by trash80 »

Thank you - I tried this:

// Database Connecting event
function Database_Connecting(&$info)
{
if (!IsLocal()) { // Not local (Production server)
        $info["host"] = "localhost";
        $info["user"] = "root";
        $info["password"] = "";
        $info["dbname"] = "demo2024";
    } else { // localhost (Test server)
        $info["host"] = "localhost";
        $info["user"] = "makephpuser";
        $info["password"] = "*******";
       $info["dbname"] = "demo2024";
    }

mobhar
User
Posts: 11905

Post by mobhar »

Double check your code. There should be a closing curly bracket at the end of your server event, like this:

// Database Connecting event
function Database_Connecting(&$info)
{
    if (!IsLocal()) { // Not local (Production server)
        $info["host"] = "localhost";
        $info["user"] = "root";
        $info["password"] = "";
        $info["dbname"] = "demo2024";
    } else { // localhost (Test server)
        $info["host"] = "localhost";
        $info["user"] = "makephpuser";
        $info["password"] = "*******";
        $info["dbname"] = "demo2024";
   } // end of if condition
} // end of Database_Connecting server event

Post Reply