1

So I have a different file called config.php which declares all the constants I will be using. I also included the config.php in the php script that I am now coding:

My php script:

    <?php
        session_start();
        //Connection Config
        include 'config.php';

        $con = new PDO('mysql:host="'. DB_HOST .'";dbname="'. DB_NAME .'"', DB_USER,DB_PASSWORD);
    ?>

In config.php:

<?php
define('DB_HOST','localhost'); 
define('DB_NAME','theclass'); //name of database
define('DB_USER','root'); //mysql user
define('DB_PASSWORD',''); //mysql password   ?>

However, WAMP is throwing an error on the $con = new PDO line giving me a fatal error. Is the parameter's used in the PDO statement correct in terms of format, because I'm not sure if I need the extra quotations around the DB variables.

Kevin Shen
  • 229
  • 3
  • 16

0 Answers0