$con = mysql_connect("47.107.159.50:3306","root","root");
After using phpstudy to configure the mysql database on the Alibaba Cloud host, the php code is linked to the database. How to fill in the database address
Oh oh oh oh oh oh
$host = '47.107.159.50';
$port = 3306;
$user = 'root';
$password = 'root';
$db_name = '表名';
if(!$con = mysqli_connect($host,$user,$password,$db_name,$port)){
echo "can not connect to databases";
}else{
if($db_name != ''){
//选择数据库
if(!mysqli_select_db($con,$db_name)){
echo "can not select database" . $db_name;
return false;
}
//发送语句
mysqli_query($con,"SET NAMES 'UTF8'");
Oh oh oh oh oh oh
$port = 3306;
$user = 'root';
$password = 'root';
$db_name = '表名';
if(!$con = mysqli_connect($host,$user,$password,$db_name,$port)){
echo "can not connect to databases";
}else{
if($db_name != ''){
//选择数据库
if(!mysqli_select_db($con,$db_name)){
echo "can not select database" . $db_name;
return false;
}
}
}
//发送语句
mysqli_query($con,"SET NAMES 'UTF8'");