usert4jju7
usert4jju7

Reputation: 1813

PHP PDO confusion

The following doesn't seem to set the $_SERVER variable in windows.

//Parse the properties
parse_ini_file("../../props/config.ini");

        //      Create a new PDO instanace
        try {
                $this->dbh = new PDO($dsn, $_SERVER['DB_USER'], $_SERVER['DB_PASS'], $options);
                // Connection succeeded, set the boolean to true.
                $this->dbcon = true;
        } catch (PDOException $e) {
                $this->error = $e->getMessage();
        }

Please could someone help me figure this out. I'd highly appreciate any help.

Upvotes: 1

Views: 109

Answers (1)

usert4jju7
usert4jju7

Reputation: 1813

Following the advice from this thread, I managed to get this working. Thank you very much to all.

Here is what I did to get this working -

Changed parse_ini_file("..\..\props\config.ini"); to

  $props =  parse_ini_file("..\..\props\config.ini");

Replaced $_SERVER with $props in $this->dbh = new PDO($dsn, $props['DB_USER'], $props['DB_PASS'], $options);

Upvotes: 1

Related Questions