PHP mysql_connect() Function
Complete PHP MySQL Reference
Definition and Usage
The mysql_connect() function opens a non-persistent MySQL connection.
This function returns the connection on success, or FALSE and an error on
failure. You can hide the error output by adding an '@' in front of the function
name.
Syntax
mysql_connect(server,user,pwd,newlink,clientflag)
|
| Parameter |
Description |
| server |
Optional. Specifies the server to connect to (can
also include a port number. e.g. "hostname:port" or a path to a local socket
for the localhost). Default value is "localhost:3306" |
| user |
Optional. Specifies the username to log in with. Default
value is the name of the user that owns the server process |
| pwd |
Optional. Specifies the password to log in with. Default is
"" |
| newlink |
Optional. If a second call is made to mysql_connect() with
the same arguments, no new connection will be established; instead, the
identifier of the already opened connection will be returned |
| clientflag |
Optional. Can be a combination of the following constants:
- MYSQL_CLIENT_SSL - Use SSL encryption
- MYSQL_CLIENT_COMPRESS - Use compression protocol
- MYSQL_CLIENT_IGNORE_SPACE - Allow space after function names
- MYSQL_CLIENT_INTERACTIVE - Allow interactive timeout seconds
of inactivity before closing the connection
|
Tips and Notes
Tip: The connection will be closed as soon as the script ends. To
close the connection before, use mysql_close().
Tip: To establish a persistent MySQL connection, use mysql_pconnect()
instead.
Example
<?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// some code
mysql_close($con);
?>
|
Complete PHP MySQL Reference
 |
 |
 |
 |
|
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |
 |
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |
 |
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Utilize the extensive out-of-the box features or customize your site through Ektron CMS400.NET's open architecture |
 |
Promote collaboration in your organization through project workspaces where others can efficiently find information and work together |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
|
|
 |
TAKE THE VIDEO TOUR |
 |
or download a FREE TRIAL today. |
|