Home > Backend Development > PHP Tutorial > PHP MySQL introductory tutorial - connecting to the database_PHP tutorial

PHP MySQL introductory tutorial - connecting to the database_PHP tutorial

WBOY
Release: 2016-07-13 17:06:24
Original
802 people have browsed it

Connecting data in PHP is accomplished by the mysql_connect() function or mysql_pconnect() function. Let me give you a brief introduction to PHP beginners.

Commonly used connection function mysql_connect()

mysql_connect(servername,username,password);

Long connection function mysql_pconnect()

mysql_pconnect(servername,username,password);

The code is as follows
 代码如下 复制代码

$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// some code
?>

Copy code


代码如下 复制代码

$conn = mysql_pconnect("localhost","root","123456") or die("Can not connect to MySQL");
echo "MySQL线程号:". MySQL_thread_id($conn). "
";
    echo "Apache进程号". getmypid();
?>

$con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); }

// some code

?> I'm talking about mysql_pconnect, how can I bypass MySQL settings. The two most important parameters affecting mysql_pconnect are wait_timeout and interactive_timeout
The code is as follows Copy code
$conn = mysql_pconnect("localhost","root","123456") or die("Can not connect to MySQL"); echo "MySQL thread number:". MySQL_thread_id($conn). "
"; echo "Apache process number".getmypid(); ?>
http://www.bkjia.com/PHPjc/630705.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630705.htmlTechArticleConnecting data in php is done by the mysql_connect() function or mysql_pconnect() function. Now I will give you an introduction to php A brief introduction by the author. Commonly used connection functions mysql_connect() mysql_connec...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template