View Single Post
  #8 (permalink)  
Old 07-30-2007, 09:12 AM
molotov molotov is offline
Novice
Join Date: Jul 2007
Posts: 37
iTrader: (0)
molotov is on a distinguished road
Let me try to epand on what TeraTask explained.

Ok, you have a server oh which your website is kept and served to the internet. Your server has what are called dameon processes (or depending on your setup, 'services') that help it act like a web server. One of these dameons is the MySQL server. The MySQL dameon operates on the entire server, for all of it's users that have the correct privileges or are in the correct group. Now as you know, MySQL deals with databases - but a single MySQL dameon can handle LOTS of databases. You have to tell it which one to use! This is where mysql_select_db() comes in; it has nothing to do with your actual SQL statements except that it tells the MySQL daemon on which database to perform the statements.

Ok, so you've got a server, with a MySQL daemon running and now you have your databases, when you connect to a database in PHP, you have to tell it the server to which you want to connect, the user* you are connecting as, as password for that user, and a database on the MySQL server that you want to use. Once you connect to the server and MySQL daemon and tell it which database to use, you can start sending it SQL statements and they will be executed on your database, and not someone else's.


Any questions?


*side note: You don't need to worry about this, but just for your information, there are two different 'types' or users here: OS users, and MySQL users. Presumably, your host has assigned you to the MySQL group, or given you the appropriate permissions. Once your OS-level user has permission to access the MySQL daemon, MySQL further requires authentication on a database-per-database level.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote