![]()
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Connection to a MySQL server and the databasePHP is a very convenient and simple tool to use databases. To use a database, the first thing to do is to connect to this database server:
Last step before being able to query the database: connect to the database itself (it is different from the database server: a database server may be used to access several databases):
From now on, it is possible to query the database using the mysql_query and a SQL query:
When we have finished to use the database, we must close the connection with the server:
The mysql_query functionThis function is used to make SQL queries to a MySQL database. The prototype for this function is this one: int mysql_query (string query [, int link_identifier])This function returns true or false depending on whether the query has succeeded or not. The link_identifier argument may be used to specify the database on which we want to make the query. If this parameter is not used, PHP uses the last contacted database. Usually, we just have to use a single database, so this argument is most of the time useless, as shown in the example above. Usually, this function is used with mysql_fetch_row or mysql_fetch_array to get the result of the SQL query row after row in an array:
Useful functions
ReferenceThe MySQL section of php.net |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Copyright © 2000-2002 themanualpage.org - This site is submissive to the terms of the GNU GPL and FDL licences. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||