Android Question PHP script does not work again

Filippo

Expert
Licensed User
Longtime User
Hi,

after the change from PHP 7.4 to PHP 8.0+ my script does not work again.
Since I don't know PHP, I need help from someone who does.


B4X:
<?php
// Anfang
include("cnf/var.php");
// Ende

$conn = new mysqli($dbhost,$dbusername,$dbpassword,$dbname);
$query = file_get_contents("php://input");

if (mysqli_errno()) {
    header("HTTP/1.1 500 Internal Server Error");
    echo $query.'\n';
    echo mysqli_error();
}
else
{
    $result = $conn->query($query);

    if (isset($_GET["select"]))
    {
        $rows = array();
        while($r = $result->fetch_assoc()) {
            $rows[] = $r;
        }
        print json_encode($rows);
    }
    elseif (isset($_GET["insert"]))
    {
        print $conn->insert_id;
    }
    else
    {
        print $sth;
    }
}
?>

The only error message I can see is this:


Why the URL is suddenly no longer valid is not clear to me.
 
Solution
Hi,

I have found the error myself.
The error is in this line:
B4X:
if (mysqli_errno()) {

the correct line is:
B4X:
if ($conn->connect_error)  {

Filippo

Expert
Licensed User
Longtime User
Hi,

I have found the error myself.
The error is in this line:
B4X:
if (mysqli_errno()) {

the correct line is:
B4X:
if ($conn->connect_error)  {
 
Upvote 0
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…