当我尝试连接到数据库时,我得到错误http 500我试过它在本地数据库上它工作正常,当我在网上上传没有工作
如果我改变我的localhost 我有三个错误
1-http 500
用户
的2连接失败访问被拒绝3连接失败无法找到mysql主机
如果有人可以提供帮助
谢谢
<?php
$Server = "localhost";
$Username = "username";
$PW = "password";
$DB = "database";
$u=filter_input(INPUT_POST, 'Username');
$p=filter_input(INPUT_POST, 'Password');
$con = mysqli_connect($Server, $Username, $PW, $DB);
if($con == false) {
die("Error: " . mysqli_error_connect());
}
$st=$con->prepare("SELECT * FROM user WHERE username = ? ");
$st->bind_param('s', $u);
$st->execute();
$rs=$st->get_result();
if ($rs->num_rows > 0) {
while ($row = $rs->fetch_assoc())
{
if ($u===$row["username"]&&$p===$row["password"])
{
echo "hi";
}
else
{
echo "Wrong username or password";
}
}
} else {
echo "wrong username or password";
}
mysqli_close($connection);
?>