PHP文件没有从我的mySQL数据库服务器检索数据

时间:2016-03-08 14:50:28

标签: php mysql

我目前正在编写Android应用程序以进行登录和注册。我发现错误来自我的php文件,因为当我尝试打开文件时它不会获取任何数据,即使它正确连接到数据库。

这是我的PHP代码:

<?php
$con=mysqli_connect("mysql7.000webhost.com","a3736257_root","********","a3736257_UD");

    if ($con->connect_error) {
         die("Connection failed: " . $conn->connect_error);
    } 
    //echo 'connection successful';

$username = 'jack';
$password = 'jackjack';

$statement = mysqli_prepare($con, "SELECT * FROM Parent WHERE username = ?  AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $username, $password);
mysqli_stmt_execute;

mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement,$parentID ,$username, $password, $email, $created, $rewardOwed);
$parent = array();

while(mysqli_stmt_fetch($statement)) {
    $parent[username] = $username;
    $parent[password] = $password;
            $parent[email] = $email;
            $parent[created] = $created;
}
echo json_encode($parent);

mysqli_stmt_close($statement);

mysqli_close($con); ?>      

这是执行代码时的输出

1 个答案:

答案 0 :(得分:0)

mysqli_stmt_execute函数不知道您希望它执行什么,除非您提供准备好的语句。函数也应该有括号()

所以:

mysqli_stmt_execute;

应该是

mysqli_stmt_execute($statement);