+ All Categories
Home > Education > Connecting to my sql using PHP

Connecting to my sql using PHP

Date post: 02-Jul-2015
Category:
Upload: nisa-soomro
View: 144 times
Download: 1 times
Share this document with a friend
Description:
How to connect PHP With MySQL
23
Course Instructor: Nisa Soomro [email protected] [email protected]
Transcript
Page 2: Connecting to my sql using PHP

With PHP, you can connect to and manipulate databases.

MySQL is the most popular database system used with PHP.

2

Page 3: Connecting to my sql using PHP

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

Page 4: Connecting to my sql using PHP

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

Orders4

Page 5: Connecting to my sql using PHP

PHP + MySQL

PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform)

5

Page 6: Connecting to my sql using PHP

A query is a question or a request.

We can query a database for specific information and have a recordsetreturned.

Look at the following query (using standard SQL):

SELECT LastName FROM Employees 6

Page 7: Connecting to my sql using PHP

7

Page 8: Connecting to my sql using PHP

8

Page 9: Connecting to my sql using PHP

9

Page 10: Connecting to my sql using PHP

10

Page 11: Connecting to my sql using PHP

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

Page 12: Connecting to my sql using PHP

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

Page 13: Connecting to my sql using PHP

13

Page 14: Connecting to my sql using PHP

14

Page 15: Connecting to my sql using PHP

15

Page 16: Connecting to my sql using PHP

16

Page 17: Connecting to my sql using PHP

17

Page 18: Connecting to my sql using PHP

18

Page 19: Connecting to my sql using PHP

19

Page 20: Connecting to my sql using PHP

20

Page 21: Connecting to my sql using PHP

21

Page 22: Connecting to my sql using PHP

22

$dbc=mysqli_connect( 'localhost', "root", "", "users");

$query = "INSERT INTO user VALUES ( 123, 'hel88');";

mysqli_query($dbc,$query );

mysqli_close($dbc);

Page 23: Connecting to my sql using PHP

www.w3school.com

Head First Php & MySQL

23


Recommended