Quakenet/#php Tutorial

Note: If you opened this page from an external URL pay attention that all chapters are linked together. Be sure you also read all prior chapters of this tutorial, otherwise you will miss relevant content explained before.

MySQL

  1. Layout of a mysql database

1. Layout of a mysql database

Whatever a php script is doing soon or later the php script must save the data somewhere. All variables are deleted after the script ends and are removed from the memory. It is possible to save these data in a file. The php script opens the file and reads or write to it as an user would edit an text file. If your create a guestbook with files as storage you can save it like this:

User|20. Jan 2008|Really good page
User2|11. Feb 2008|Hi Paul, how are you?
User3|13. Feb 2008|Cool page, visit my homepage too

Each row will be a guestbook entry and the character | is the delimiter for usernames, creation date and the text. The php script reads this file and use explode to get the three parts back.

For a relational database like MySQL a different approach is taken. The data are not saved in files but in tables. Each row in the table represents an entry. MySQL is using the following layout.

To you a MySQL database in php you need 4 values. You get them from the administrator of your webserver.

  1. Host - This is the address to the server where mysql is installed. It can be any IP or host like db23.example.com but is often the same computer as the webserver is running. In this case the host is localhost

  2. Username - The username to login.

  3. Password - The password to login.

  4. Database - The database to work with. A webapplication always use only one database.

Questions about the chapter

No questions

Back to Next to
Copyright © to the OPs of #php/QuakeNet Valid XHTML 1.0 Strict Valid CSS!