Home >Backend Development >PHP Tutorial >php常用的conn写法??非常非常弱的问题

php常用的conn写法??非常非常弱的问题

WBOY
WBOYOriginal
2016-06-23 14:21:301793browse

第一天接触php,看的w3教程。问题很弱、分很少,别见怪。

mysql下可能会有多个库(库01,库02,库03)
在写conn.php的时候,是不是应该写成下面这样?

<?php$conn=mysql_connect("mysql数据库的地址","用户名","密码")mysql_select_db("库01", $conn);?>


然后在所有文件中




回复讨论(解决方案)

是的 

数据库名最好用英文,这样更稳定。

嗯,是这样子

conn.php
$conn=mysql_connect("mysql数据库的地址","用户名","密码");

search,php
include 'conn.php';
mysql_select_db("库01", $conn);
...
mysql_close($conn);
include 'conn.php';
mysql_select_db("库02", $conn);
...
mysql_close($conn);
include 'conn.php';
mysql_select_db("库03", $conn);
...
mysql_close($conn);
?>

Statement:
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