php脚本错误我的mysql连接错误

时间:2017-02-23 11:16:13

标签: php mysql

这是我的剧本

<?php
  define('HOST','databases.000webhost.com/localhost');
  define('USER','id847165_user');
  define('PASS','qwertyuiop');
  define('DB','id847165_db');
  $con = mysqli_connect(HOST,USER,PASS,DB);

  $name = $_POST['name'];
  $address = $_POST['address'];

    $sql = "insert into Persons (name,address) values ('$name','$address')";
  if(mysqli_query($con,$sql)){
    echo 'success';
  }
  else{
    echo 'failure';
  }
  mysqli_close($con);
?>

这是我的错误

Warning: mysqli_connect(): (HY000/2002): Connection refused in /storage/h5/165/847165/public_html/db.php on line 6

Notice: Undefined index: name in /storage/h5/165/847165/public_html/db.php on line 8

Notice: Undefined index: address in /storage/h5/165/847165/public_html/db.php on line 9

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /storage/h5/165/847165/public_html/db.php on line 12
failure
Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /storage/h5/165/847165/public_html/db.php on line 18

screenshot of database enter image description here

任何人都可以帮助我纠正错误

0 个答案:

没有答案