php连接mysql数据库连接测试文件
2012-11-17 09:39
459 查看
<?php define("RelativePath", "."); include_once(RelativePath."/DB_mysql.class.php"); # DB_mysql.class.php 在我的资源里面 $db_mysql = new DB_mysql(); $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 } ?>
相关文章推荐
- php中使用mysqli和pdo扩展,测试连接mysql数据库的效率。
- php5.3.x连接mssql测试文件(ODBC连接方式)
- PHP连接mysql数据库之根据配置文件选择mysqli还是pdo方式
- Mac配置php.ini文件,连接mysql数据库
- PHP连接mysql数据库导出csv文件
- 如何使用JSON连接Android和PHP Mysql数据库
- php 单文件测试代码时必加入的代码
- PHP PDO ACCESS 留言板-连接数据库包含文件inc.php
- PHP同时连接多个mysql数据库实例代码
- PHP使用mysqli扩展连接MySQL数据库
- MyEclipse下测试连接MySQL数据库
- PHP 连接新浪云,mySQL数据库时,出错的问题解决
- PHP连接SQLSERVER 注意事项(附dll文件下载)
- PHP 连接mysql数据库
- PHP读取Excel文件的内容并写入Mysql数据库
- PHP连接SQL SERVER 数据库 PHP连接MYSQL数据库并解决中文乱码问题。
- php连接mysql数据库
- php测试mysql数据库连通性并且在浏览器每一秒输出一次结果
- PHP中用mysqli面向对象打开连接关闭mysql数据库
- 备份mysql数据库的php代码(一个表一个文件)