Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced PHP: Using PHP with MySQL C. Daniel Chase The University of Tennessee at Chattanooga.

Similar presentations


Presentation on theme: "Advanced PHP: Using PHP with MySQL C. Daniel Chase The University of Tennessee at Chattanooga."— Presentation transcript:

1 Advanced PHP: Using PHP with MySQL C. Daniel Chase The University of Tennessee at Chattanooga

2 Overview ● Introduction to PHPMyAdmin to Manage MySQL ● MySQL Management ● Introduction to Database Design ● Creation of Databases ● Using PHP with MySQL ● Useful PHP Functions

3 PHPMyAdmin ● Web-based interface for managing MySQL ● Download from phpmyadmin.net ● Can install in user web space—ours is in system-wide location: http://localhost/phpmyadmin/ http://localhost/phpmyadmin/ ● Setup by editing config.inc.php – For auth_type config ● Set controluser & controlpass – Read-only access to mysql/user – Read-only access to mysql/db ● Set user & pass

4 PHPMyAdmin Configuration ● Setup by editing config.inc.php – For auth_type config ● Set controluser & controlpass – Read-only access to mysql/user – Read-only access to mysql/db ● Set user & pass – For auth_type http ● Set auth_type to http ● Set controluser & controlpass as above ● Set user & pass to “” ● Do Not Set Apache to require authentication! ● Trick: With NEW MySQL Install, Use PHPMyAdmin to create & set passwords in MySQL BEFORE doing above

5 Managing MySQL with PHPMyAdmin ● Adding Users ● Setting passwords ● Note: These are Exclusive to MySQL! ● Granting Rights – Database level access control – Table level control – Field level control – Operation control – Remote location limits

6 Database Design ● Database Normalization ● First Normal form – Each column contains atomic values – Each column has unique name – Table has unique Primary Key – No two rows identical – No repeating groups of data ● Second Normal Form – Applies only to multi-column primary keys – Move data only dependent on part of primary key

7 Database Design ● Third Normal Form – Remove transitive dependencies—column not directly reliant on primary key, but on another that is ● Relationships – One-to-Many – One-to-One – Many-to-Many

8 Creation of Databases ● New Database require MySQL root privileges ● If using http authentication, admin can create database & users authorized to access, then allow access for user to create actual tables, etc. ● Grant appropriate Rights to User ● Suggest admin creating – Database level admin user with full rights – Database level read-only user with SELECT only rights

9 Using PHP with MySQL ● Create connection to MySQL – $conn = mysql_connect(“localhost”, “username”, “password”) or die (“Could not connct to database”); – $conn = mysql_pconnect(“localhost”, “username”, “password”) or die (“Could not connct to database”); ● Select database – $db = mysq_select(“database”) or die(“Could not select database”); ● Send Query – $result = mysql_query(“SELECT * FROM table”) or die(mysql_error());


Download ppt "Advanced PHP: Using PHP with MySQL C. Daniel Chase The University of Tennessee at Chattanooga."

Similar presentations


Ads by Google