php连接mysql数据库连接测试文件
程序员文章站
2022-06-17 12:12:10
...
[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
}
?>
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
}
?>
上一篇: 详细解读PHP $_FILES数组的内容
下一篇: PHP Redis 装配
推荐阅读
-
完美解决MySQL通过localhost无法连接数据库的问题
-
nodejs进阶(6)—连接MySQL数据库示例
-
JSP连接MySql/MS SQL Server/Oracle数据库连接方法[整理]
-
Python连接mysql数据库及python使用mysqldb连接数据库教程
-
myeclipse连接mysql数据库详细步骤(实战mysql数据库引擎)
-
详解MySQL数据库--多表查询--内连接,外连接,子查询,相关子查询
-
详解使用navicat连接远程linux mysql数据库出现10061未知故障
-
Spring Boot 与 Kotlin 使用JdbcTemplate连接MySQL数据库的方法
-
使用数据库客户端工具Oracle SQL Developer加载第三方驱动连接mysql的方法
-
Java对MySQL数据库进行连接、查询和修改操作方法