当前位置:编程学习 > php >>

PHP整站程序如何修改conn.php 连接数据库

使用说明如下: 执行http://域名-恢复数据库. 修改/conn.php /inc/conn.php里的数据库连接 后台地址为http://域名/admin账号密码都是admin conn.php打开如下 <? mysql_connect("localhost","lfggw","lfggw"); mysql_select_db("niuchao513"); mysql_query("set names 'gbk'"); date_default_timezone_set('PRC'); function Q($str){ return mysql_query($str); } function R($str){ return mysql_fetch_array(mysql_query($str)); } function F($result){ return mysql_fetch_array($result); } function mstr($str, $start, $len) { $tmpstr = ""; $strlen = $start + $len; for($i = 0; $i < $strlen; $i++) { if(ord(substr($str, $i, 1)) > 0xa0) { $tmpstr .= substr($str, $i, 2); $i++; } else $tmpstr .= substr($str, $i, 1); } return $tmpstr; } function showi($str,$url){ if($url=="-1"){ echo "<script>alert('$str');history.go(-1);</script>"; } else{ echo "<script>alert('$str');location.href='$url';</script>"; } exit; } function goi($url){ if($url=="-1"){ echo "<script>history.go(-1);</script>"; } else{ echo "<script>location.href='$url';</script>"; } exit; } function GetIP() { if(!empty($_SERVER["HTTP_CLIENT_IP"])) { $cip = $_SERVER["HTTP_CLIENT_IP"]; } else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { $cip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else if(!empty($_SERVER["REMOTE_ADDR"])) { $cip = $_SERVER["REMOTE_ADDR"]; } else { $cip = ''; } preg_match("/[\d\.]{7,15}/", $cip, $cips); $cip = isset($cips[0]) ? $cips[0] : 'unknown'; unset($cips); return $cip; } function GetTitle($id){ $r=R("select t from fafa where id='$id'"); return $r['t']; } $userid=getcookieid(); function getcookieid(){ $uid=@$_COOKIE['fafa_userid']; if($uid==""){ $uid=0; } return $uid; }
追问:

我该怎么填写呢

mysql_connect("localhost","lfggw","密码"); 
mysql_select_db("lfggw");
答案:mysql_connect("localhost","用户名","密码"); 
mysql_select_db("数据库名");
其他:打开直接修改哟 楼上正解 建议你使用mysqli,面向对象的,比起mysql来说方便多了,数据连接mysqli(‘h’,‘u’,‘p','d'),然后返回给一个对象就行了

上一个:上海初级php程序员工资多少呢,,,说说一般情况吧
下一个:我应届毕业生,目前网页设计和美工的工作,以后想做PHP程序员,请问美工到PHP程序员是不是一个过度关系?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,