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

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

WBOY
Release: 2016-06-23 14:21:30
Original
1795 people have browsed it

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

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

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


然后在所有文件中




回复讨论(解决方案)

是的 

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

嗯,是这样子

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);
?>

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