mysql_connect()


利用提供的账号信息试图向MySQL服务器连接

Description

false/int mysql_connect(string $server, string $user_name, string $raw_pwd)

Parameters

Return Value

成功时true,失败时false

Example

<?php
include_once "/lib/sn_dns.php";     // include DNS library
include_once "/lib/sn_mysql.php";

$server_addr = "192.168.0.100";     // IP address of MySQL server
$user_name = "user_id";             // MySQL ID
$password = "password";             // MySQL password

// connect to a MySQL server
if(mysql_connect($server_addr, $user_name, $password) === false)
    exit(mysql_error());            // print the error message and quit

mysql_close();                      // disconnecting from the MySQL server
?>

See also