Lecture 12 - PHP and MySQL - annotated

Lecture 12 - PHP and MySQL - annotated - PHP and MySQL...

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

View Full Document Right Arrow Icon
1 PHP and MySQL INFO/COM S 230: Intermediate Web Design and Programming Reminder Midterm March 11 (Tuesday) 7:30-9PM Olin 155 Finally We’ve studied two topics Today they come together Easy PDF Creator is professional software to create PDF. If you wish to remove this line, buy it now.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 How it works Another view Using MySQL from PHP Connecting To use MySQL from PHP you first need to connect to it (like opening a file). mysql_connect( hostname, username, password); Returns a MySQL DB link if successful, false otherwise. E.g. $link = mysql_connect(‘localhost’, ‘dpwmson’, ‘mypassword’); Selecting a DB mysql_select_db( dbname , link ); Selects DB dbname for use given connection link . E.g. mysql_select_db(‘moviesdb’, $link); Issuing SQL commands mysql_query( sqlquery , dblink ); Issues sqlquery to MySQL DB given by dblink. • For INSERT, UPDATE, DELETE, returns true if successful, false if not • For SELECT, returns resource if successful, false if not. E.g. $result = mysql_query(“SELECT * FROM Movies”, $link); Easy PDF Creator is professional software to create PDF. If you wish to remove this line, buy it now.
Background image of page 2
3 We don’t know and we don’t care! We pass the output of these calls as input to future MySQL calls. Getting results mysql_fetch_array( resource, arg ); Returns array containing next tuple from relation given by resource , or false if no more tuples. • If
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2008 for the course INFO 2300 taught by Professor Williamson during the Spring '08 term at Cornell.

Page1 / 7

Lecture 12 - PHP and MySQL - annotated - PHP and MySQL...

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

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