PHP AND MYSQL.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
PHP and MySQL. Why Use a Database  Easy access to data  Simultaneous access by multiple users is handled properly  Security - easy to control access.
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
Manipulating MySQL Databases with PHP. PHP and mySQL2 Objectives Connect to MySQL from PHP Learn how to handle MySQL errors Execute SQL statements with.
Objectives Connect to MySQL from PHP
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
PHP Data Object (PDO) Khaled Al-Sham’aa. What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform interface.
Web Application Development. Define ER model in QSEE Generate SQL Create Database mySQL Write Script to use TableEditor class Process to create A simple.
Web Application Development. Tools to create a simple web- editable database QSEE MySQL (or PHPMyAdmin) PHP TableEditor.
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
 Mysql – popular open-source database management system  PHP usually works with Mysql for web- based database applications  LAMP applications—Web-based.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
MySQL and PHP 3 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
Lec_6 Manipulating MySQL Databases with PHP PHP Programming with MySQL.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP Part 2.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Lecture 10 – MYSQL and PHP (Part 2)
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
MySQL Database Connection
Pengantar Teknologi Internet W14: Server Scripting & Database.
PHP - MySQL Connection 8 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
PHP Database Processing CIS 1715 Web Technologies.
Information Building and Retrieval Using MySQL Track 3 : Basic Course in Database.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
THE WEBMASTERS: SENG + WAVERING.  On account of construction, we will be having class in room 1248 next week.
PHP Workshop ‹#› PHP Data Object (PDO). PHP Workshop ‹#› What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP Data Object (PDO)
MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.
Database MySQL Universitas Muhammadiyah Surakarta Yogiek Indra Kurniawan.
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
Windows 7 WampServer 2.1 MySQL PHP 5.3 Script Apache Server User Record or Select Media Upload to Internet Return URL Forward URL Create.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
CSC 405: Web Application Engineering II8.1 Web programming using PHP What have we learnt? What have we learnt? Underlying technologies of database supported.
PHP with MYSQL Please use speaker notes for additional information!
PHP MySQL1 PHP and MySQL After this lecture, you should be able to:  Access a MySQL database with PHP  mysql_connect()  mysql_select_db()  mysql_query()
Introduction to Database Programming with Python Gary Stewart
PHP & MY SQL Instructor: Monireh H. Sayadnavard 1.
Tried my best to simplify it for you!
Remote hosts and web servers
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Session 4 PHP & MySQL.
PHP: Output Formatting
PHP-language, database-programming
Accessing Your MySQL Database from the Web with PHP (Ch 11)
PHP: Database Basic Selection FdSc Module 109
PHP: Combo box FdSc Module 109 Server side scripting and
PHP: Database connection
Web Programming– UFCFB Lecture
Updating Databases With Open SQL
Database Access with PHP and MySQL
Updating Databases With Open SQL
Presentation transcript:

PHP AND MYSQL

PHP and MySQL PHP has functions that allow access to MySQL Databases Access is very easy 1. Connect 2. Select Database 3. Query 4. Close connection

1. Connect $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password');

2. Select Database $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password'); $db_selected = mysql_select_db('foo', $link);

3. Query $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password'); $db_selected = mysql_select_db('foo', $link); $result = mysql_query("DELETE FROM table;", $link);

4. Close $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password'); $db_selected = mysql_select_db('foo', $link); $result = mysql_query("DELETE FROM table;", $link); mysql_close($link);

mysql_query INSERT, UPDATE, DELETE, DROP SELECT Returns true or false Returns resource on success, false on error The returned resource should be passed to mysql_fetch_array()

Retrieving Table $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password'); $db_selected = mysql_select_db('foo', $link); $result = mysql_query("SELECT * FROM table;", $link); while ($row = mysql_fetch_array($result)) { print($row[0]); print($row[1]); } mysql_close($link);

Retrieving Table $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password'); $db_selected = mysql_select_db('foo', $link); $result = mysql_query("SELECT * FROM table;", $link); while ($row = mysql_fetch_array($result)) { print($row["id"]); print($row["name"]); } mysql_close($link);

Error Handling Every function in the previous code examples could fail Connection can fail, sql query can fail etc. Usually you exit the script when DB fails. With exit($status) – function, you can stop the execution of the script.

Example of Error Handling 1 $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password'); if( ! $link ) { exit("Error connecting to database"); }

Example of Error Handling 2 $link = mysql_connect('mysql_server', 'mysql_user', 'mysql_password') or exit("Error connecting to database");