How to Run a PHP MySQL Project in XAMPP Step by Step

PHP Student Project Setup Guide

How to Run a PHP MySQL Project in XAMPP Step by Step

You downloaded a PHP project, extracted the ZIP file, opened the folder, and found dozens of PHP files plus a database file. Now you need to make the project work on localhost. This guide takes you through the complete process: installing XAMPP, finding the real project folder, importing the SQL database, updating the connection file, opening the correct localhost URL, and fixing the errors students commonly see.

Quick answer: Install XAMPP, start Apache and MySQL from the XAMPP Control Panel, extract the project into C:\xampp\htdocs, create a database in phpMyAdmin, import the included .sql file, update the PHP database connection file, and open http://localhost/project-folder/.

XAMPP PHP MySQL and MariaDB phpMyAdmin SQL import htdocs localhost errors

What You Need Before Starting

XAMPP gives you the local server components required to run many PHP projects. It normally includes Apache for serving web pages, PHP for executing the project code, MariaDB for the database, and phpMyAdmin for managing that database through a browser.

Many project pages still call the database “MySQL.” Current XAMPP packages use MariaDB, which is compatible with many beginner MySQL projects. However, very old SQL files or projects that depend on a specific database version can still show compatibility errors.

Project source code

You need the extracted PHP project folder. Do not try to run PHP files directly from inside a ZIP or RAR archive.

Database file

Look for a file ending in .sql. It may be named database.sql, project.sql, db.sql, or something related to the project.

Local server

Install XAMPP from Apache Friends. Avoid downloading modified installers from unknown software sites.

XAMPP is for local development. Do not expose a default XAMPP installation directly to the public internet. Its default configuration prioritizes convenient development rather than production security.

Inspect the Project Before Moving Files

A downloaded ZIP often contains more than one folder level. Copying the wrong folder into htdocs creates confusing URLs and “Object not found” errors.

After extracting the ZIP, locate the folder that contains files such as:

index.php
login.php
config.php
connection.php
includes/
admin/
assets/
css/
js/
database.sql

The correct project root usually contains index.php, although some projects begin with login.php, home.php, or a file inside an admin folder.

Find the SQL file

Search these common locations:

project-folder/database/
project-folder/db/
project-folder/sql/
project-folder/Database/
project-folder/admin/database/
project-folder/

If the project has several SQL files, look for documentation or inspect the files in a text editor. The main file usually contains many CREATE TABLE statements. A smaller file may contain only sample data or an update.

Find the database connection file

Common names include:

config.php
db.php
database.php
connection.php
connect.php
dbconnection.php
includes/config.php
config/database.php
admin/includes/config.php

Search the project for terms such as mysqli_connect, new mysqli, new PDO, DB_NAME, or localhost. This usually reveals the file that controls the database connection.

How to Run the Project in XAMPP

1

Install XAMPP

Download and install XAMPP. The common Windows installation location is C:\xampp. Installing in a simple path avoids many permission and path problems.

During installation, keep Apache, PHP, MariaDB or MySQL, and phpMyAdmin enabled. These are the main components needed for a traditional PHP database project.

2

Start Apache and MySQL

Open the XAMPP Control Panel and click Start beside Apache and MySQL. The rows should normally become highlighted and display running process IDs and ports.

Apache serves your PHP pages. The database service stores the project data. Most PHP MySQL projects need both services running.

3

Test localhost

Open this address in your browser:

http://localhost/

If the XAMPP dashboard opens, Apache is working. If the browser cannot connect, fix Apache before changing the project files.

4

Move the project into htdocs

Copy the extracted project folder into:

C:\xampp\htdocs\

For example:

C:\xampp\htdocs\student-management-system\

Use a short folder name with letters, numbers, and hyphens. Avoid spaces, unusual symbols, and unnecessarily deep folder nesting.

5

Open phpMyAdmin

Visit:

http://localhost/phpmyadmin/

phpMyAdmin is the browser interface you will use to create the project database, import the SQL file, and inspect the tables.

6

Determine the required database name

Before creating a random database, inspect the PHP connection file and SQL file. Look for a database name such as:

$database = "student_db";

Or SQL lines such as:

CREATE DATABASE student_db;
USE student_db;

The database name in phpMyAdmin should match the name used by the PHP project unless you update the connection file.

7

Create the database

In phpMyAdmin, click New, enter the required database name, and click Create.

For a basic student project, a modern UTF-8 collation is normally appropriate. If the SQL file explicitly expects another collation, use the project requirement or resolve any import error carefully instead of changing random SQL lines.

8

Import the SQL file

Select the newly created database in the left sidebar. Click the Import tab, choose the project’s .sql file, and start the import.

After a successful import, tables should appear under the database. Common table names include users, admin, students, orders, products, or settings.

9

Update the database connection

Open the project connection file and make sure the host, username, password, and database name match your local XAMPP setup.

A common default local setup uses localhost, username root, an empty password, and the database name you created. Your installation may differ if you changed the root password.

10

Open the project through localhost

If the folder is named student-management-system, open:

http://localhost/student-management-system/

Do not double-click index.php and open it as a local file. PHP must be processed through Apache using a localhost URL.

How to Configure the PHP Database Connection

A typical MySQLi connection may look like this:

connect_error) {
    die("Database connection failed: " . $conn->connect_error);
}

?>

A PDO connection may look like this:

setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $error) {
    die("Database connection failed: " . $error->getMessage());
}

?>
Connection value Common local XAMPP value What it must match
Host localhost The database server location.
Username root Your local database account.
Password Often empty by default The password configured for the local database user.
Database name Project-specific The database you created or imported in phpMyAdmin.
Port 3306 unless changed The port used by the running database service.

Do not replace every connection file you find. Some projects have one configuration for the public website and another for the admin panel. Search the entire project and update only the real connection settings.

Test More Than the Home Page

A project opening successfully does not prove the database and features work. Test the full workflow before assuming the setup is complete.

  1. Open the home page without PHP warnings.
  2. Open the admin or user login page.
  3. Use the documented credentials or inspect the relevant database table.
  4. Create a test record.
  5. Edit the record.
  6. Delete the record if the project supports deletion.
  7. Log out and log back in.
  8. Upload an image or file if uploads are part of the project.
  9. Check whether dashboard totals update.
  10. Review the database tables to confirm changes were saved.

This is a basic CRUD test: create, read, update, and delete. It helps you separate a working interface from a genuinely working project.

Admin login does not automatically equal admin/admin. Check the project documentation, SQL comments, project page, or the admin/users table. Passwords may be stored as hashes, so changing the visible database value without understanding the code may break login.

Common XAMPP Project Errors and What to Check

Error or symptom Likely cause First fix to try
Apache does not start Port 80 or 443 is already in use, permissions are blocked, or configuration is invalid. Open the Apache log and XAMPP Netstat view. Identify the conflicting service before changing ports.
MySQL does not start Port 3306 conflict, damaged database files, permission issue, or an improper previous shutdown. Read the database error log and back up the data folder before attempting repair steps.
Object not found or 404 Wrong URL, wrong folder name, or project not inside htdocs. Compare the exact folder name with the localhost URL.
Directory listing appears The folder does not contain a recognized start file such as index.php. Find the real project root or open the correct entry file.
Database connection failed Wrong host, username, password, database name, or connection port. Compare the connection file with phpMyAdmin and XAMPP settings.
Unknown database The configured database was not created or has a different name. Create the expected database or update the PHP configuration.
Table does not exist The SQL file was not imported, was imported into the wrong database, or failed partway through. Check whether the expected tables exist and review the import message.
Access denied for user root The project password does not match the local database account. Use the actual local password. Do not assume the password is empty if you changed it.
Blank white page A fatal PHP error is hidden, or a required file cannot be loaded. Check the Apache/PHP error log and temporarily enable development error reporting.
Login page reloads without success Wrong credentials, failed session handling, missing database row, password-hash mismatch, or form-field mismatch. Inspect the users/admin table and follow the login query in the PHP code.
CSS or images do not load Hardcoded paths, wrong project folder name, missing assets, or incorrect base URL. Use the browser Network tab to find the exact failed asset URL.
SQL import error Collation mismatch, duplicate database, unsupported syntax, foreign key order, large file, or version incompatibility. Keep the original SQL backup and troubleshoot the exact phpMyAdmin error.

Temporarily show PHP errors during local debugging

Add this near the beginning of the failing PHP file only while debugging locally:

Remove or disable visible error output before deploying a real website. Detailed errors can reveal file paths, database details, and internal code information.

Do not follow random repair videos that tell you to delete database files such as ibdata1 without understanding the consequences. Back up C:\xampp\mysql\data and read the database error log first. A careless repair can destroy local databases from other projects.

Why Older Downloaded PHP Projects May Not Work

A project can be packaged correctly and still fail because it was written for an older PHP version. This is common with source-code projects uploaded many years ago.

Old mysql_* functions

If the code contains functions such as:

mysql_connect()
mysql_query()
mysql_select_db()

The project uses PHP’s old MySQL extension. That extension was removed in PHP 7. Modern projects should use MySQLi or PDO instead.

Do not simply rename mysql_connect() to mysqli_connect() and assume the project is fixed. Query calls, result handling, escaping, error handling, and function arguments may also need updating.

Other version-related problems

  • Removed or deprecated PHP functions.
  • Strict type or warning changes.
  • Old password-hashing logic.
  • Deprecated dynamic properties.
  • Outdated framework dependencies.
  • SQL modes that reject older loose data.
  • Old collations not available in the installed database version.

Check the project’s publication date, README, framework version, and PHP requirements before rewriting large sections. Sometimes using a compatible development environment is useful for inspection, but upgrading the code is better for a serious submission or portfolio project.

Turn a Running Project Into a Finished Student Project

Getting the home page to open is only the first stage. A strong project submission should also include working database operations, understandable code, documentation, testing notes, screenshots, and viva preparation.

Setup

Extract the project, identify the root folder, locate the SQL file, and create a repeatable installation checklist.

Database

Import the SQL successfully, understand the tables, and verify that CRUD operations change real records.

Debugging

Fix errors using logs and exact messages rather than changing unrelated files randomly.

Understanding

Read the login flow, database connection, modules, user roles, and important queries.

Documentation

Prepare the abstract, objectives, modules, database notes, testing, screenshots, conclusion, and future scope.

Originality

Improve the project with meaningful design, security, feature, reporting, or workflow changes that you can explain.

Related CodeZips Tools and Guides

PHP Project Setup Guide Generator for XAMPP

Enter your project folder, SQL file, database name, connection-file location, and local server details to generate a personalized setup checklist.

SQL File Doctor for XAMPP and phpMyAdmin

Check SQL files for missing tables, database-name clues, foreign key problems, old export patterns, collations, and likely phpMyAdmin import issues.

PHP/XAMPP Error Fixer

Use this when Apache, MySQL, localhost, phpMyAdmin, database connections, PHP warnings, or project paths are failing.

How to Fix MySQLi Connection and XAMPP Localhost Errors

Follow a focused guide for access denied, unknown database, connection refused, missing tables, and mismatched configuration values.

XAMPP vs WAMP vs Laragon

Compare popular Windows local-server options before choosing the environment for your PHP and database project.

Student Project Documentation Generator

After the project runs, generate editable sections for the abstract, objectives, modules, database design, testing, conclusion, and future scope.

ER Diagram Generator from SQL

Paste your project’s table definitions to understand entities, relationships, database structure, and likely database viva questions.

Source Code to Viva Simulator

Paste an important PHP file to generate code explanations, teacher-style questions, database logic notes, and weak areas to revise.

Technical References

Frequently Asked Questions

Where do I put a PHP project in XAMPP?

On Windows, place the extracted project folder inside C:\xampp\htdocs. A folder named my-project normally opens through http://localhost/my-project/.

How do I import the project database?

Open phpMyAdmin, create or select the required database, click the Import tab, choose the project’s SQL file, and run the import. Confirm that the expected tables appear afterward.

What database name should I use?

Check the project connection file and SQL file. The database name created in phpMyAdmin must match the name in the PHP configuration unless you update that configuration.

Why does localhost show Object not found?

The project may not be inside htdocs, the URL may not match the folder name, or you may have copied an outer ZIP folder instead of the actual project root.

Why does the project say database connection failed?

Check the host, username, password, database name, and port in the connection file. Also confirm that the database service is running and the database exists in phpMyAdmin.

Why does the project show a blank white page?

A PHP fatal error may be hidden. Check the Apache and PHP error logs or temporarily enable PHP error display in the local development environment.

Why does an old project show undefined function mysql_connect?

The project uses PHP’s removed original MySQL extension. It must be updated to MySQLi or PDO, or inspected in a compatible legacy environment before being modernized.

Can I upload my XAMPP folder directly to a live server?

No. XAMPP is a local development environment, not a production deployment package. Upload the application files separately, create a production database, update secure credentials, and configure a proper hosting environment.

Final Takeaway

Most PHP project setup failures come from five places: the wrong project folder, the wrong localhost URL, a missing or failed SQL import, a database name that does not match the connection file, or an old project that is incompatible with the installed PHP version. Check those areas in order before rewriting code. Once the project runs, test its real database features, understand the important files, document the workflow, and make meaningful improvements you can explain during your viva.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top