MySQL: Access Via PHP

Similar documents
Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015

Professional PHP for working with MySQL

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist.

Locate your Advanced Tools and Applications

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Installing LAMP on Ubuntu and (Lucid Lynx, Maverick Meerkat)

Lecture 13: MySQL and PHP. Monday, March 26, 2018

PHP Development - Introduction

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

Host at 2freehosting.Com

Joomla 3.X Global Settings Part III Server Settings

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

2017 Politecnico di Torino 1

2017 Politecnico di Torino 1

Download and Installation Instructions: After WAMP Server download start the installation:

Database Connectivity using PHP Some Points to Remember:

Installing Joomla

INSTALLING RACHEL ON SYNOLOGY GIAKONDA IT

CHAPTER 10. Connecting to Databases within PHP

SQL Server Deployment Installation Manual. Call a Hygiena representative for more information or support

Database Systems. phpmyadmin Tutorial

Apache, Php, MySql Configuration

PHP Arrays. Lecture 20. Robb T. Koether. Hampden-Sydney College. Wed, Feb 28, 2018

A340 Laboratory Session #17

Linux Network Administration. MySQL COMP1071 Summer 2017

Objectives. Chapter 10. Developing Object-Oriented PHP. Introduction to Object-Oriented Programming

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

Databases and MySQL: The Basics

Symantec Security. Setup and Configuration Guide

IU RGRbench Workload/Benchmark User Guide to Database Creation and Population

Quick Guide to Installing and Setting Up MySQL Workbench

Developing Online Databases and Serving Biological Research Data

Using PHPMyAdmin with WordPress

What is WAMP5? Top Next

Chapters 10 & 11 PHP AND MYSQL

Install Apache, PHP And MySQL On CentOS 7 (LAMP)

Module 3 MySQL Database. Database Management System

PHP: Hypertext Preprocessor. A tutorial Introduction

MYSQL DATABASE ACCESS WITH PHP

Oracle Database Express Edition

CentOS 6.7 with Vault MySQL 5.1

Locate your Advanced Tools and Applications

Setting up a LAMP server

Securing MySQL Please Fill Out The Evaluation at: Abstract ID Sheeri Cabral PalominoDB, Inc

1 Login AppServ Hosting Control System

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier

LABSHEET 1: creating a table, primary keys and data types

The MANUAL. 1 P a g e

AutoMate BPA Server 10 Installation Guide

REV OBSERVER for WINDOWS

Connecting BioNumerics to MySQL

Including Dynamic Images in Your Report

MySQL: Querying and Using Form Data

LAB 3 Basic Switch Configuration Commands

Introduction to relational databases and MySQL

Bitnami HHVM for Huawei Enterprise Cloud

AppWizard Installation/Upgrade Guide (v.4.00)

! Quick review of ! normalization! referential integrity ! Basic MySQL ! Other types of DBs

Bitnami JRuby for Huawei Enterprise Cloud

Installing Dolphin on Your PC

ITC 250/CPET 499 Web Systems Nov. 3, 2016 Managing MySQL Database Part 3 of 3

Using MySQL on the Winthrop Linux Systems

Setup Guide. Page 0

AutoMate BPA Server 9 Installation Wizard

Bitnami ProcessMaker Community Edition for Huawei Enterprise Cloud

Bitnami Pimcore for Huawei Enterprise Cloud

WebEA Quick Start Guide

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information.

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

IBM DB Getting started with Data Studio Hands-On Lab. Information Management Cloud Computing Center of Competence.

CallerID Lookup Sources User Guide

Working with Databases

Table of Contents. Single Sign On 1

Bitnami Dolibarr for Huawei Enterprise Cloud

Securing MySQL. Presented by: Sheeri K. Cabral Senior DBA & Community Liasion, PalominoDB

PHP and MySQL Programming

ApsaraDB for RDS. Quick Start (PostgreSQL)

Database connection 1

COMP 250. Lecture 27. hashing. Nov. 10, 2017

Database Management Systems Design. Week 6 MySQL Project

Comp 519: Web Programming Autumn 2015

HOW TO CONNECT TO CAC DATABASE SERVER USING MySQL

Bitnami Coppermine for Huawei Enterprise Cloud

Setting up Omeka on IU s Webserve

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:

Installing MySQL on the Command Line

Plugin Monitoring for GLPI

Install instructions for Windows

PHP and MySgi. John Wiley & Sons, Inc. 24-HOUR TRAINER. Andrea Tarr WILEY

Managing Workflows. Starting Prime Network Administration CHAPTER

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

Installing phpmyadmin On Linux

Getting Started with PHP

AN INTRODUCTION TO WEB PROGRAMMING. Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

Troubleshooting. The NLR Web Interface Does not Appear CHAPTER

Install and make Apache + PHP to work with PosgreSQL database server on Debian Linux and set up server Web Posgre interface Pgpadmin howto

Remote Access Via Remote Desktop

TaskMaster Documentation INSTALLATION GUIDE

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL

Transcription:

MySQL: Access Via PHP CISC 282 November 15, 2017 phpmyadmin: Login http://cisc282.caslab. queensu.ca/phpmyadmin/ Use your NetID and CISC 282 password to log in 2

phpmyadmin: Select DB Clicking on this icon will log you out Select your database named db_netid by clicking on it 3 phpmyadmin: New Table Create a new table by entering its name and the number of attributes 4

phpmyadmin: New Table Specify the data types for each field and click Save At least one column must be set as the primary key 5 phpmyadmin: Add Records These tabs allow you to perform any SQL command on the database Add new records by entering values here All the database's tables are listed here 6

phpmyadmin: Alter Records Click here to edit a record Click here to delete a record 7 PHP and MySQL Prior to PHP 5.0 Interact with a database using mysql_... functions These either require or return a resource Use to access the database and execute statements As of PHP 5.0 Use the improved MySQL functionality Known as MySQLi What are the improvements? Object-oriented approach with procedural aliases Support for prepared statements Better debugging and more 8

Functional MySQLi Aliased functional versions of object-oriented functions Listed in the PHP manual online Functional alias is provided for each object-oriented method The slides and examples in this course will use the objectoriented approach You may use the functional versions in your assignment 9 Object-Oriented MySQLi Equivalent to... "mysql h hostname u username p password" on the command line May need to use localhost for hostname "USE dbname;" in MySQL (optional) $mysqli = new mysqli("hostname", "username", "password", "dbname"); Returns a MySQLi object To connect on the CISC 282 server use your NetID as username use your CISC 282 password as password use dbname db_netid 10

Plaintext Password?!?! It is bad practice to store passwords in plaintext Extremely unsecure should someone read the code At a systems level, password files are heavily encrypted Option 1: obfuscate or encrypt the password Will need to de-obfuscate or decrypt to use What if someone gains access to the server? Can reverse the process and get the values Option 2: set default values in a PHP config file Used by the MySQLi constructor if arguments are missing What if someone gains access to the server? Can get the values using phpinfo() Can log in using the defaults 11 Plaintext Password?!?! Option 3: restrict the MySQL account Only permit the bare minimum for that user Unable to do much damage What do people actually do? Often, not much Generally, either options 1 & 3 or 2 & 3 There's not a lot of consensus on the best practice You don't have to deal with this for your assignments But you should if you encounter this professionally 12

Error Handling $mysqli >errno; The error code from the last fail-able command Not all function calls can fail or cause an error The property is an integer value 0 if no error occurred $mysqli >error The error message from the last fail-able command The property is a string value 13 $mysqli >connect_errno $mysqli >connect_error Error Handling Connection-specific versions of the above $mysqli >connect_error available from PHP 5.2.9/5.3.0 Use mysqli_connect_error() instead for earlier versions die(errormsg) Use in combination with MySQLi error handling Forces the PHP script to print an error message and exit e.g., if ($mysqli >connect_errno) { die($mysqli >connect_error); } Useful for debugging, but not so great for users 14

Connection Functions $mysqli >select_db("databasename") Equivalent to "USE databasename;" in MySQL Returns FALSE if the database could not be chosen Returns TRUE otherwise On the CISC 282 server, use database db_netid $mysqli >close() Equivalent to "quit" in MySQL Closes the database connection for $mysqli Returns TRUE if the connection was closed and FALSE otherwise 15