MySQL function library: mysql_connect

Source: Internet
Author: User
Keywords mysql_connect mysql function Library php Chinese function manual
Tags aliyun function function library hostname html http link mysql

Mysql_connect

(PHP3, PHP4)

Mysql_connect---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Open MySQL server connection

Syntax: int mysql_connect ([string hostname [:p ort] [:/path/to/socket] [, String username [, string password]])

Description:

Success returns a positive number of MySQL link identifier, failure returns the error message.

Mysql_connect () set up MySQL server link, all parameters are not required, if you do not give the parameter value, the default is assumed to be (' localhost ', with the server processing user name, no password).

Hostname can also include port numbers, such as "hostname:port" or the socket path, for example: ":/path/to/socket"

Note: ":p ort" is added to the PHP3.0B4, PHP3.0.10 provides ":/path/to/socket", and you can use ' @ ' (@mysql_connect ()) to suppress the message returned when the error occurs.

If the second call to Mysql_connect () with the same parameters, no new link will be established, but will be returned to the previously opened knot identifier to replace.

When the program is finished, the connection to the server is immediately closed unless the mysql_close () is called earlier to close.

Example:

<?php

$link = mysql_connect ("Kraemer", "Marliesle", "secret") or Die ("could not Connect");

Print ("Connected successfully");

Mysql_close ($link);

?>

Reference: Mysql_pconnect () mysql_close ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.