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 8741979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:25:00+00:00 2026-06-13T11:25:00+00:00

Hi I just finished reading a beginner book on PHP and I wana start

  • 0

Hi I just finished reading a beginner book on PHP and I wana start to create my own login.I did not get very far and I got an error that I can;t seem to fix.

I have 3 files

    index.php

    session_start();
    require 'DB_ACCES/connect.php';

    if(isset($_POST['submit'])){
        $conn = new Mysqli();
    }

    constants.php

    define('DB_HOST', 'localhost');
    define('DB_USER' , 'root');
    define('DB_PWD' , '');

    connect.php

    require '../includes/constants.php';

    class Mysqli{

        private $conn;

        function __construct() {
            $this->conn = new mysqli(DB_HOST , DB_USER , DB_PWD) or die(mysqli_error());
        }
    }

When I run index.php I get this error:

Fatal error: Cannot redeclare class Mysqli in D:\Program Files\xampp\htdocs\MyWork\Blog\DB_ACCES\connect.php on line 4

What am I doing wrong here and how can I repair it?

  • 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-13T11:25:01+00:00Added an answer on June 13, 2026 at 11:25 am

    The bug is exactly what the error states.

    Mysqli is an existing class that’s part of a very common php shared library mysqli. You can’t redeclare it.

    Change your classname to MyMysqli or something.

    class MyMysqli{
    
        private $conn;
    
        function __construct() {
            $this->conn = new mysqli(DB_HOST , DB_USER , DB_PWD) or die(mysqli_error());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Perl programming. I've just finished reading the Llama book. Up
I just finished reading about scoping in the R intro , and am very
I just finished create my own wordpress theme. But when I checked the html
I recently forced myself to study C++ and I just finished reading the book
I just finished reading a book on scala. What strikes me is that every
I've just finished reading 'Java for Dummies' and have begun to create a simple
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
Just finished reading Jon Skeet's article about events and delegates and got a question.
I just finished reading the HTML5 Developer's Cookbook and have a question. I've read
I just finished the Django tutorial and started work on my own project, however,

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.