Notice: Use of undefined constant DB_HOST - assumed 'DB_HOST' in C:\xampp\htdocs\blog\system\functions.php on line 31

后端 未结 3 453
无人及你
无人及你 2021-01-05 23:32

Getting a couple of errors and can\'t for the life of me see where I am falling down. Below is the functions file



        
相关标签:
3条回答
  • 2021-01-05 23:44

    that means DB_HOST is not defined or DB_HOST is not accessible in the current context.

    Try place these varibles in the script at the begining instead of include('config.php');

    define('DB_HOST','mysql:host=localhost;dbname=blog');
    define('DB_USER','root');
    define('DB_PASS','');
    
    0 讨论(0)
  • 2021-01-05 23:46

    The constants you are using for Host, User and Password haven't been defined yet. There's probably something wrong with your config.php.

    0 讨论(0)
  • 2021-01-06 00:08

    Use particular terms in place of reference...

    For e.g.

    $dbh = new PDO(DB_HOST, DB_USER, DB_PASS);
    

    Change to...

    $dbh = new PDO('localhost', 'root', '')
    

    That would work.

    0 讨论(0)
提交回复
热议问题