form action="" method="post"
我們提供的服務(wù)有:成都做網(wǎng)站、成都網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、遠(yuǎn)安ssl等。為成百上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的遠(yuǎn)安網(wǎng)站制作公司
select name="host"
option value="localhost" selectedlocalhost/option
option value="127.0.0.1"127.0.0.1/option
/select
brbr
user:input type="text" name="user" value=""brbr
pwd :input type="passWord" name="pwd" value=""brbr
input type="submit" value="connent"
input type="reset" value="reset"
/form
?php
error_reporting(~E_ALL);
$host = $_POST['host'];
$user = $_POST['user'];
$pwd = $_POST['pwd'];
if(isset($_POST['host']) isset($_POST['user']) isset($_POST['pwd'])){
if(strlen($host)1 or strlen($user)1 or strlen($pwd)1){
echo "請完善相關(guān)數(shù)據(jù)庫鏈接信息。";
exit(0);
}
$conn = mysql_connect($host, $user, $pwd) or die("Error-數(shù)據(jù)庫連接失??!");
if($conn){
echo "OK—數(shù)據(jù)庫連接成功!";
}
}
?
?php
$link=mysql_connect("localhost","root","123");
if(!$link) echo "連接錯誤";
else echo "OK!可以連接";
?
mysql_connect( )函數(shù)為:服務(wù)器名或IP、用戶名,密碼。
$host='XXX';
$user='XX';
$pass='XXX';
$db='edu';
$conn=@mysql_connect($host,$user,$pass);
if(!$conn){
echo 'script alert("數(shù)據(jù)庫錯誤");window.location.href="XX.php";/script';
}
else{
mysql_select_db($db,$conn);
}
mysql_query("SET NAMES UTF8");