SlideShare a Scribd company logo
Course Instructor: Nisa Soomro 
nisa1207@gmail.com 
prog_nisa@quest.edu.pk
With PHP, you can connect to and 
manipulate databases. 
MySQL is the most popular database system 
used with PHP. 
2
 MySQL is a database system used on the web 
 MySQL is a database system that runs on a server 
 MySQL is ideal for both small and large applications 
 MySQL is very fast, reliable, and easy to use 
 MySQL supports standard SQL 
 MySQL works on many operating systems and with many languages including 
PHP, PERL, C, C++, JAVA, etc. 
 MySQL compiles on a number of platforms 
 MySQL is free to download and use 
 MySQL is developed, distributed, and supported by Oracle Corporation 
 MySQL is named after co-founder Monty Widenius's daughter: My 
3
The data in MySQL is stored in tables. A table is a 
collection of related data, and it consists of columns 
and rows. 
Databases are useful when storing information 
categorically. A company may have a database with 
the following tables: 
Employees 
Products 
Customers 
Orders 
4
PHP + MySQL 
PHP combined with MySQL are cross-platform 
(you can develop in Windows 
and serve on a Unix platform) 
5
A query is a question or a request. 
We can query a database for specific 
information and have a recordset 
returned. 
Look at the following query (using 
standard SQL): 
SELECT LastName FROM 
Employees 6
7
8
9
10
Use the PHP mysqli_connect() function to open a new connection 
to the MySQL server. 
Open a Connection to the MySQL Server 
Before we can access data in a database, we must open a 
connection to the MySQL server. 
 In PHP, this is done with the mysqli_connect() function. 
Syntax 
mysqli_connect( host, username, password, dbname); 
11
Syntax 
mysqli_connect( host, username, password, dbname); 
12 
Parameter Description 
host Either a host name or an IP address 
username The MySQL user name 
password The password to log in with 
dbname Optional. The default database to be used when 
performing queries
13
14
15
16
17
18
19
20
21
$dbc=mysqli_connect( 'localhost', "root", "", "users"); 
22 
$query = "INSERT INTO user VALUES ( 123, 
'hel88');"; 
mysqli_query($dbc,$query ); 
mysqli_close($dbc);
 www.w3school.com 
 Head First Php & MySQL 
 
23

More Related Content

PPT
The benefits of My sql
PPTX
File handling
PDF
Introduction to SQLite in Adobe AIR
PPTX
MySql:Exporting And Importing Data In Mysql
PPT
Mysql grand
PPT
Php connectivitywithmysql
PPT
Getting started into mySQL
The benefits of My sql
File handling
Introduction to SQLite in Adobe AIR
MySql:Exporting And Importing Data In Mysql
Mysql grand
Php connectivitywithmysql
Getting started into mySQL

What's hot (16)

PDF
MySQL 简要介绍
PDF
MySQL without the SQL -- Cascadia PHP
PPTX
Develop PHP Applications with MySQL X DevAPI
PPTX
MySQL Record Operations
PPTX
Sq lite
PPTX
PPT
Working with Databases and MySQL
PDF
Better Data Persistence on Android
PPT
Mysql Repair Software:-Repairs Corrupted MySQL database
PPT
My sql and jdbc tutorial
PPTX
My sql with java
PDF
The big data technology landscape-V.Janaki-II-M.Sc computer Science
PPT
Introducción a la Arquitectura de OpenLaszlo
PPT
Sqlite
PPTX
Create Database
PPT
My sql basic
MySQL 简要介绍
MySQL without the SQL -- Cascadia PHP
Develop PHP Applications with MySQL X DevAPI
MySQL Record Operations
Sq lite
Working with Databases and MySQL
Better Data Persistence on Android
Mysql Repair Software:-Repairs Corrupted MySQL database
My sql and jdbc tutorial
My sql with java
The big data technology landscape-V.Janaki-II-M.Sc computer Science
Introducción a la Arquitectura de OpenLaszlo
Sqlite
Create Database
My sql basic
Ad

Viewers also liked (7)

PPTX
PPTX
PPTX
PHP Filing
PPTX
Form Handling using PHP
PPTX
Basic of PHP
PPTX
PHP Cookies and Sessions
PDF
Getting Information through HTML Forms
PHP Filing
Form Handling using PHP
Basic of PHP
PHP Cookies and Sessions
Getting Information through HTML Forms
Ad

Similar to Connecting to my sql using PHP (20)

PPTX
Lecture1 introduction by okello erick
PPTX
Web programming
ODP
PPTX
3-Chapter-Edit.pptx debre tabour university
PPT
Php classes in mumbai
PPT
Php and MySQL Web Development
PPTX
Database Connectivity in PHP
PPTX
Data types and variables in php for writing and databse
PPTX
introduction to backend with php 8.X - slide.pptx
PPT
Sql php-vibrant course-mumbai(1)
PPT
Synapse india reviews on php and sql
PPT
PHP - Intriduction to MySQL And PHP
PPTX
SRMS 5th Sem Minor project.pptx
PPTX
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
PPT
PHP and MySQL
PDF
Php simple
PDF
Php summary
PDF
Responsive WEB APP using cakePHP
PPTX
Php reports sumit
Lecture1 introduction by okello erick
Web programming
3-Chapter-Edit.pptx debre tabour university
Php classes in mumbai
Php and MySQL Web Development
Database Connectivity in PHP
Data types and variables in php for writing and databse
introduction to backend with php 8.X - slide.pptx
Sql php-vibrant course-mumbai(1)
Synapse india reviews on php and sql
PHP - Intriduction to MySQL And PHP
SRMS 5th Sem Minor project.pptx
FYBSC IT Web Programming Unit V Advanced PHP and MySQL
PHP and MySQL
Php simple
Php summary
Responsive WEB APP using cakePHP
Php reports sumit

More from Nisa Soomro (11)

PPTX
HTML Basic Tags
PPTX
HTML Forms
PPTX
HTML Frameset & Inline Frame
PPTX
HTML Images
PPTX
HTML Lists & Llinks
PPTX
HTML Tables
PPTX
Html5 SVG
PPTX
Html5 Canvas Detail
PPTX
Html5 canvas
PPTX
PPTX
Web programming lec#3
HTML Basic Tags
HTML Forms
HTML Frameset & Inline Frame
HTML Images
HTML Lists & Llinks
HTML Tables
Html5 SVG
Html5 Canvas Detail
Html5 canvas
Web programming lec#3

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
master seminar digital applications in india
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Lesson notes of climatology university.
PDF
Classroom Observation Tools for Teachers
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Yogi Goddess Pres Conference Studio Updates
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Pharma ospi slides which help in ospi learning
Final Presentation General Medicine 03-08-2024.pptx
master seminar digital applications in india
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Lesson notes of climatology university.
Classroom Observation Tools for Teachers
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Final Presentation General Medicine 03-08-2024.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
Yogi Goddess Pres Conference Studio Updates
O5-L3 Freight Transport Ops (International) V1.pdf
Microbial disease of the cardiovascular and lymphatic systems
Anesthesia in Laparoscopic Surgery in India
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Module 4: Burden of Disease Tutorial Slides S2 2025
A systematic review of self-coping strategies used by university students to ...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
GDM (1) (1).pptx small presentation for students
Pharma ospi slides which help in ospi learning

Connecting to my sql using PHP

  • 2. With PHP, you can connect to and manipulate databases. MySQL is the most popular database system used with PHP. 2
  • 3.  MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications  MySQL is very fast, reliable, and easy to use  MySQL supports standard SQL  MySQL works on many operating systems and with many languages including PHP, PERL, C, C++, JAVA, etc.  MySQL compiles on a number of platforms  MySQL is free to download and use  MySQL is developed, distributed, and supported by Oracle Corporation  MySQL is named after co-founder Monty Widenius's daughter: My 3
  • 4. The data in MySQL is stored in tables. A table is a collection of related data, and it consists of columns and rows. Databases are useful when storing information categorically. A company may have a database with the following tables: Employees Products Customers Orders 4
  • 5. PHP + MySQL PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform) 5
  • 6. A query is a question or a request. We can query a database for specific information and have a recordset returned. Look at the following query (using standard SQL): SELECT LastName FROM Employees 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. 10
  • 11. Use the PHP mysqli_connect() function to open a new connection to the MySQL server. Open a Connection to the MySQL Server Before we can access data in a database, we must open a connection to the MySQL server.  In PHP, this is done with the mysqli_connect() function. Syntax mysqli_connect( host, username, password, dbname); 11
  • 12. Syntax mysqli_connect( host, username, password, dbname); 12 Parameter Description host Either a host name or an IP address username The MySQL user name password The password to log in with dbname Optional. The default database to be used when performing queries
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. $dbc=mysqli_connect( 'localhost', "root", "", "users"); 22 $query = "INSERT INTO user VALUES ( 123, 'hel88');"; mysqli_query($dbc,$query ); mysqli_close($dbc);
  • 23.  www.w3school.com  Head First Php & MySQL  23