UbiComp27Nov04 - PHP/MySQL tutorial Karl Quinn 27th...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
PHP/MySQL tutorial Karl Quinn 27 th November 2004 Ubiquitous Computing M.Sc. 2004 (year one)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction PHP (Hypertext Preprocessor) - Open source, server-side, scripting language. - Supports databases such as MySQL and Oracle. - http://www.w3schools.com/php/default.asp MySQL (Structured Query Language) - Open source, speedy, scalable, reliable database technology. - http://dev.mysql.com/doc/mysql/en/Tutorial.html
Background image of page 2
Tutorial Overview Database (MySQL) - DB creation - Add/delete tables - Add/delete/update records - View/query records Web (PHP) - User front-end - Add & query code - Delete & update code
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MySQL & TCD (1) ‘ PuTTY ’ into wilde.cs.tcd.ie on port 22 w/ SSH - Authenticate with your TCD username and password (2) ssh macneil.cs.tcd.ie (password as above) (3) Login into your MySQL account ‘mysql –uUSERNAME –p’ Enter your MySQL username and password (4) Use MySQL syntax to create and view table(s), records, etc.
Background image of page 4
Basic MySQL Syntax SHOW DATABASES; USE database_name; SHOW TABLES; DROP TABLE table_name;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Create MySQL Table CREATE TABLE user (name varchar(9) NOT NULL, id int(6) NOT NULL, PRIMARY KEY (id), UNIQUE (id) );
Background image of page 6
Add/Delete/Update Table INSERT INTO user VALUES (‘bond’, ‘007’); DELETE FROM user WHERE id=‘007’; UPDATE user SET name=‘BOND’ WHERE id=‘007’;
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Query Database SELECT * FROM user; SELECT * FROM user WHERE name=‘BOND’; SELECT DISTINCT name FROM user; SELECT name, id FROM user ORDER BY name;
Background image of page 8
PHP User Front-End <html> <body> <?php $variable=“271004"; echo $variable; ?> </body> </html> Script is executed server side and presented to user via a browser. PHP code is rendered as plain HTML.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
<? // configuration parameters // database configuration $host = "macneill.cs.tcd.ie"; $user = “username"; $pass = “password"; $db = “username_db"; // default contact person $def_contact = “Karl"; ?> Use a securely
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

UbiComp27Nov04 - PHP/MySQL tutorial Karl Quinn 27th...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online