PHP-MySQL 2024/25 Internet Tech & Website Design PDF

Document Details

EntertainingCatharsis

Uploaded by EntertainingCatharsis

Ndejje University

2024

Tags

php mysql database management web development

Summary

These notes provide an introduction to PHP and MySQL, covering database concepts including creating databases and tables, and inserting and extracting data from a database using PHP code snippets. The content emphasizes important steps in working with these technologies.

Full Transcript

Php-mysql Internet Tech & Website Design 2024/25 Introduction In this lesson, you will bring together your PHP and SQL knowledge. Target: Script that connects to the dbms & selects a database Script that creates a database.  Script that creates a table Script...

Php-mysql Internet Tech & Website Design 2024/25 Introduction In this lesson, you will bring together your PHP and SQL knowledge. Target: Script that connects to the dbms & selects a database Script that creates a database.  Script that creates a table Script to insert records in the table created Script to extract records from the table Open a Connection to MySQL DBMS  Before we can access database in the MySQL dbms, we need to connect to the database server:  Connection string: mysqli_connect(server_name, user_name, password)  To select an already existing database, u add database name as the 4th parameter to the connection string. mysqli_connect(server_name, user_name, password, db_name) Note:  The connection string must be included in every script in which interact with the database is intended.  The DBMS login details used are for learning purposes, in a real world environment a password is never null. connect.php PHP Create a MySQL Database A database consists of one or more tables. You will need special CREATE privileges to create or to delete a MySQL database. Create a MySQL Database The CREATE DATABASE statement is used to create a database in MySQL. The following examples create a database named “db2024” In this case we use connect.php on slide-4 to connect to the DBMS. Note After successfully creating the database “db2024”, the connection string must change to include database selection.  Note: For all scripts below, we will include “conn.php” in which a 4th parameter is added to the selection string. To select an already created database, we add the database name as a parameter to the connection string. conn.php

Use Quizgecko on...
Browser
Browser