Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:52:02+00:00 2026-06-07T11:52:02+00:00

Here is the config.php file <?php error_reporting(E_ALL ^ E_NOTICE); /*=========== Database Configuraiton ==========*/ $db_host

  • 0

Here is the config.php file

<?php

error_reporting(E_ALL ^ E_NOTICE);

/*=========== Database Configuraiton ==========*/

$db_host = "localhost";
$db_user = "test";
$db_pass = "test";
$db_name = "dbtest";


/*=========== Website Configuration ==========*/

$defaultTitle = 'testing';
$defaultFooter = date('Y').' &copy; testing';

?>

Here is the reference to config.php

<?php


require_once "includes/config.php";
require_once "includes/connect.php";
require_once "includes/helpers.php";



header('Cache-Control: max-age=3600, public');
header('Pragma: cache');
header("Last-Modified: ".gmdate("D, d M Y H:i:s",time())." GMT");
header("Expires: ".gmdate("D, d M Y H:i:s",time()+3600)." GMT");

?>

Connect.php is below

<?php

/*
        The login details are taken from config.php.
*/

try {
    $db = new PDO(
        "mysql:host=$db_host;dbname=$db_name;charset=UTF-8",
        $db_user,
        $db_pass
    );

    $db->query("SET NAMES 'utf8'");
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {
    error_log($e->getMessage());
    die("A database error was encountered");
}


?>

Does anyone see the problem with this code? I am getting the error message from connect.php “a database error was encountered” I need another set of eyes because all my info looks correct and I can’t see the error in the code. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:52:04+00:00Added an answer on June 7, 2026 at 11:52 am

    Once try with your credentials directly instead of using them as variable.

    also try to debug using below:

    catch(PDOException $e) {
        error_log($e->getMessage());
        die("A database error was encountered -> " . $e->getMessage() );
    }
    

    Let me know if it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: //Connect to config file include(dirname(__FILE__)./../config.php); //Connect to the database $db
i use a file ( ss-config.php ) which contains informations about servor and database
I have created a file name database.php and here is it's content <?php #Start
I'm trying to install ibrowser for tinymce. Here's the config file: $cfg['ilibs'] = array
Here is my code: if (file_exists('config.php')) { require('config.php'); // This is line 38 }
I have a Yii project with a main.php config file and dev.php config file
I have these three files to work with: document_root/include/config.php document_root/include/database.php document_root/index.php And the relevant
Here is the config from shiro.ini shiro.loginUrl = /login.jsp ######### URL CONFIG ################### [urls]
I'm using the ASP.Net SqlMembershipProvider to manage my users. Here is my config: <membership
Here is the web.config; <?xml version=1.0 encoding=UTF-8?> <configuration> <system.web> <customErrors mode=Off> </customErrors> <authentication mode=Forms>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.