Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does php have a mysql_connect function?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "is there a mysql_connect function in php?" the editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope that this article "does php have mysql_connect function" can help you solve the problem.

There is a "mysql_connect ()" function in PHP. This function is used to open a non-persistent MySQL connection, which returns a MySQL connection ID for success and false for failure, with the syntax "mysql_connect (server, user name, password, newlink,clientflag)".

This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.

Php has a mysql_connect function

The mysql_connect () function opens a non-persistent MySQL connection.

Grammar

Mysql_connect (server,user,pwd,newlink,clientflag)

Server is optional. Specify the server to connect to. You can include the port number, such as "hostname:port", or the path to the local socket, such as ": / path/to/socket" for localhost. If the PHP directive mysql.default_host is not defined (default), the default value is' localhost:3306'.

User is optional. User name. The default value is the user name of the server process owner.

Pwd is optional. Password. The default value is an empty password.

Newlink is optional. If mysql_connect () is called a second time with the same parameters, no new connection will be established, but the identity of the connection that has already been opened will be returned. The parameter new_link changes this behavior and causes mysql_connect () to always open a new connection, even when mysql_connect () has been called with the same parameter earlier.

Clientflag is optional. The client_flags parameter can be a combination of the following constants:

MYSQL_CLIENT_SSL-use SSL encryption

MYSQL_CLIENT_COMPRESS-use compression protocol

MYSQL_CLIENT_IGNORE_SPACE-the interval after the name of the allowed function

MYSQL_CLIENT_INTERACTIVE-allows interaction timeout inactivity before closing the connection

Return value

A MySQL connection ID is returned if successful, or FALSE if failed.

Examples are as follows:

This is the end of the introduction about "does php have mysql_connect function?" Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report