Home  >  Article  >  Backend Development  >  关于用php连接mysql数据库的有关问题

关于用php连接mysql数据库的有关问题

WBOY
WBOYOriginal
2016-06-13 11:21:39780browse

关于用php连接mysql数据库的问题

function PA{<br />global $host,$user,$pw,$name;<br />    $conn = mysql_connect("$host","$user","$pw"); <br />    mysql_select_db("$name",$conn) or die("不能选择数据库:".mysql_error());<br />    unset($dbhost,$dbuser,$dbpw,$dbname);<br />}


这是一个源码,为什么这里user和pw都没有赋值?这是怎么实现连接mysql的? 写这代码的人把密码和用户名放在别的地方了?还是这个mysql没有设定用户名和密码?
大神们指点下吧。谢谢

PHP MySQL
------解决方案--------------------
global $host,$user,$pw,$name;
不是已经告诉你那些变量在别处吗?

另外 unset($dbhost,$dbuser,$dbpw,$dbname); 是画蛇添足
因为 global 生命的变量都是引用方式的,删了也等于没删
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