php文件在实时服务器上显示错误

时间:2018-06-21 22:18:01

标签: php mysql sql-server

我尝试在网站上上传php文件以从表单中获取数据,该文件运行正常,但在运行时却显示错误。

错误是: 警告:mysqli_connect():(HY000 / 1044):用户'ideamak1_sagar'@'%'对第12行/home/ideamak1/public_html/afterform.php中数据库'ideamak1_data'的访问被拒绝 错误:无法连接gh。

这是我的php代码

<!DOCTYPE html>
<head>
</head>
<body>
  <?php
  $name = $_POST['name'];
  $email = $_POST['email'];
  $contact = $_POST['contact'];

  $comment = $_POST['comment'];

  $link = mysqli_connect("localhost", 
  "ideamak1_sagar", "Jmtm,?j4T(ZD", 
   "ideamak1_data") or die("ERROR: Could 
  not connect gh. ");
if(isset($_POST['name']) && 
  isset($_POST['email'])){
    $sql = "INSERT INTO user (name, email, 
 contact, comment) VALUES ('$name', 
 '$email', '$contact', '$comment')";
    $result = mysqli_query($link, $sql) or 
 die("ERROR: Could not connect. ");
    mysqli_close($link);
?>
    <h1>Thank You for Contacting Us <?php 
echo "<span 
style='color:purple;'>$name</span>"   ?> 
 </h1>

        <h3>We will be contacting you 
 soon</h3>      <a href="index.html">Click 
  here for redirecting site..</a

            <?php
    }else{
?>  <p>Your account have been not 
 registered yet.</p>
            <a href="index.html">Click here 
 for redirecting site..</a>
    <?php }?>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

  

error_reporting(E_ERROR | E_PARSE);

将其放在PHP的顶部,它将停止显示错误消息。这不能解决您的错误。但这听起来像是您只想拥有一个不错的显示。