我有一个 php 脚本,可以在请求页面时更改数据库。这是php:
<?php
date_default_timezone_set('EST');//set time zone
$con=mysqli_connect("baukin.fatcowmysql.com","sas","***pass***","dbname");//establish connection
// Check connection
if (mysqli_connect_errno())//ping database to check connection
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();//error message
}
else
{
echo "Successfully updated database";//success message
}
mysqli_query($con,"UPDATE dryers SET STATE='$_GET[state]' WHERE MACHINEID ='$_GET[machine_id]' ");//update state
mysqli_query($con,"UPDATE dryers SET UPDATETIME=date('m/d/y H:i:s') WHERE MACHINEID = '$_GET[machine_id]' ");//update time
mysqli_close($con);//close connection
?>
我收到此错误:
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2005): Unknown MySQL server host 'server' (0) in /home/content/57/10410357/html/updatedatabase.php on line 3
Failed to connect to MySQL: Unknown MySQL server host 'server' (0)
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/content/57/10410357/html/updatedatabase.php on line 13
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/content/57/10410357/html/updatedatabase.php on line 15
Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /home/content/57/10410357/html/updatedatabase.php on line 17
我是php新手,知道为什么吗?