android - 将数据写入服务器,php脚本错误

时间:2017-03-11 11:17:21

标签: php android

我正在尝试创建一个可以将简单信息存储到服务器中的Android应用程序。我使用webspace作为存储。我试图运行我的服务器的PHP脚本返回错误

 Connection refused in /storage/h2/940/646940/public_html/phpcode.php on line 7
 Connection failed: Connection refused

我的php脚本:

<?php
$servername = "xxx.com";
$username = "xxx";
$password = "xxx";
$dbname = "idxxx_demo";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$Wann=$_POST['Wann'];
$Wo = $_POST['Wo'];
$Was = $_POST['Was'];
$Zahl = $_POST['Zahl'];
$sql = "INSERT INTO demotabe (Wann,Wo,Was,Zahl,Option)
VALUES ('{$Wann}','{$Wo}','{$Was}','{$Zahl}','{$Option}')";
if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?> 

0 个答案:

没有答案