PHP connection MySQL database connection test file _php Tutorial

Source: Internet
Author: User
Tags php define
[PHP]
Define ("RelativePath", ".");
Include_once (RelativePath. " /db_mysql.class.php "); # DB_mysql.class.php in My resources
$db _mysql = new Db_mysql (); Www.2cto.com
$db _mysql->set_values ("localhost", "* * *", "* * *", "* * *");
# eg: "localhost", "root", "" "," test "
# eg: "localhost or remote IP address", "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 (the "Can ' t use". $db _mysql->mysql_remote_db_name. " "." The error message is "." ". Mysql_error ($db _selected));
}
/*
else{
echo "has successfully selected:". " ". $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
}
?>

http://www.bkjia.com/PHPjc/477909.html www.bkjia.com true http://www.bkjia.com/PHPjc/477909.html techarticle [PHP]? PHP define (RelativePath,.); include_once (relativepath./db_mysql.class.php); # DB_mysql.class.php in my resources $ Db_mysql = new Db_mysql (); www.2cto.com $db _mysql-se ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.