Frequently Used MySQL Library Functions
This chapter develops applications using the following PHP calls:
-
resourcemysql_pconnect([stringhost[:port]],[stringusername],[stringpassword]) Used to establish a connection to the MySQL DBMS. Upon success, the function returns a connection resource handle that can be used to access databases through subsequent function calls. It returns
falseon failure.
The function has three optional parameters. The first is the
host name of the DBMS and an optional
port number; a default port of 3306 for
MySQL is assumed if the port is omitted. The
host parameter is usually set to
localhost when the MySQL DBMS and the web server
are running on the same machine.
The username and
password are MySQL DBMS username and
password credentials. These are the same username and password used
to access the DBMS though the command-line monitor
mysql.
-
int mysql_select_db (stringdatabase, [resourceconnection]) Use the specified
databasethrough theconnection. The connection is a resource handle returned frommysql_pconnect( ). The second parameter is optional but always recommended in practice. The function returnstrueon success andfalseon failure.-
resource mysql_query(string SQL, [resourceconnection]) Run an SQL statement through a MySQL DBMS
connection. The second parameter is optional but always recommended in practice. On success, the function returns a query result resource that can be used to fetch data. The function returnsfalse ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access