I am currently coding an Android app for login and registration. I have discovered that the error is coming from my php file as when I try and just open the file it does not fetch any of the data even though it is connecting correctly to the database.
This is my PHP code here:
<?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); ?>
This is the output when I execute the code
The mysqli_stmt_execute function doesn't know what you want it to execute unless you provide it with the prepared statement. Also functions should have parenthesis ()
.
So:
mysqli_stmt_execute;
should be
mysqli_stmt_execute($statement);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.