Home > php教程 > php手册 > php连接mysql数据库连接测试文件

php连接mysql数据库连接测试文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:53:09
Original
1160 people have browsed it

[php] 
  define("RelativePath", "."); 
  include_once(RelativePath."/DB_mysql.class.php"); # DB_mysql.class.php 在我的资源里面  
  $db_mysql = new DB_mysql();  www.2cto.com
  $db_mysql->set_values("localhost","***","***","***"); 
  # eg: "localhost","root","","test" 
  # eg: "localhost或远程IP地址","root","","test" 
  $link = mysql_connect($db_mysql->mysql_remote_db_host,$db_mysql->mysql_remote_db_username,$db_mysql->mysql_remote_db_password); 
  if(!$link){ 
    die("Not connectted:".mysql_error($link)); 
  } 
  $db_selected = mysql_select_db($db_mysql->mysql_remote_db_name,$link); 
  if(!$db_selected){ 
    die("Can't use ".$db_mysql->mysql_remote_db_name." "."错误提示为"." ".mysql_error($db_selected)); 
  } 
  /*
  else{
    echo "已经成功选择:"." ".$db_mysql->mysql_remote_db_name;
  }
  */ 
  $sql = "select user_id,user_email from user_info limit 100"; 
  $query = mysql_query($sql,$link);  
  if(!$query){ 
    die(mysql_error($query)); 
  } 
  else{ 
    # $num_rows = mysql_num_rows($query); 
    # echo $num_rows; 
    echo mysql_num_rows($query); # the result is 100 
  }     
?> 

 

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template