首页  >  文章  >  后端开发  >  php连接mysql数据库连接测试文件_PHP教程

php连接mysql数据库连接测试文件_PHP教程

WBOY
WBOY原创
2016-07-14 10:06:45951浏览

[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 
  }     
?> 

 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477909.htmlTechArticle[php] ?php define(RelativePath, .); include_once(RelativePath./DB_mysql.class.php); # DB_mysql.class.php 在我的资源里面 $db_mysql = new DB_mysql(); www.2cto.com $db_mysql-se...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn