Page 1 of 1

Database Connecting on different machines

Posted: Tue Aug 27, 2024 12:56 pm
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!!!


Re: Database Connecting on different machines

Posted: Tue Aug 27, 2024 1:37 pm
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.


Re: Database Connecting on different machines

Posted: Tue Aug 27, 2024 1:54 pm
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";
    }

Re: Database Connecting on different machines

Posted: Tue Aug 27, 2024 2:06 pm
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