$con = mysql_connect("47.107.159.50:3306","root","root");
在阿里云主机使用phpstudy配置mysql数据库后php代码链接到数据库,数据库地址怎么填写
刘宁2019-01-23 09:49:19
$host = '47.107.159.50';
$port = 3306;
$user = 'root';
$password = 'root';
$db_name = '表名';
if(!$con = mysqli_connect($host,$user,$password,$db_name,$port)){
echo "无法连接到数据库" ;
}else{
if($db_name != ''){
//选择数据库
if( !mysqli_select_db($con,$db_name)){
echo "无法选择数据库" 。 $db_name;
return false;
}
}
}
//发送语句
mysqli_query($con,"设置名称'UTF8'");