PHP Automatically adding whitespaces

49 Views Asked by At

I have an API in PHP with PDO. All of my queries on my laptop itself work fine, but the moment i test it on a different pc, some methods don't. I am using the exact same version of xampp so I find it out. I echoed out the query and it looks like this :

Edit~ As Per Suggestion, I have turned it into AND

SELECT*FROM afbeelding WHERE record_id=: record_id AND tabelnaam=: tabelnaam

This happens for every pc and also my laptop. Though on my laptop it functions fine^

The section where all of this happens is underneath :

$base_query = "SELECT * FROM afbeelding WHERE record_id = :record_id AND tabelnaam = :tabelnaam";

            echo $base_query;
            $qry = $this->CONN->prepare($base_query);
            $qry->bindParam(":record_id", $record_id);
            $qry->bindParam(":tabelnaam", $tabelnaam);
            $qry->execute();




            if ($qry->rowCount() == 0) {
                http_response_code(404);
                print_r(json_encode(["message" => "No Results Found"]));
                return;
            }

            $response = $qry->fetchAll(PDO::FETCH_ASSOC);

I'm not particularly sure why it does this, but it's effecting the other pcs

Result on my laptop returns :

SELECT*FROM afbeelding WHERE record_id=: record_id AND tabelnaam=: tabelnaam[
    {
        "id": 12,
        "img_url": "image0-1708893712681.png",
        "record_id": 1,
        "tabelnaam": "product"
    },
    {
        "id": 13,
        "img_url": "image1-1708893712685.png",
        "record_id": 1,
        "tabelnaam": "product"
    },
    {
        "id": 14,
        "img_url": "image2-1708893712686.png",
        "record_id": 1,
        "tabelnaam": "product"
    },
    {
        "id": 15,
        "img_url": "image3-1708893712698.png",
        "record_id": 1,
        "tabelnaam": "product"
    },
    {
        "id": 21,
        "img_url": "image0-1709673514264.png",
        "record_id": 1,
        "tabelnaam": "product"
    },
    {
        "id": 22,
        "img_url": "image0-1709673523113.png",
        "record_id": 1,
        "tabelnaam": "product"
    }
]

While on other pcs it returns :

SELECT*FROM afbeelding WHERE record_id=: record_id AND tabelnaam=: tabelnaam
    {'message':'No Results Found'}
0

There are 0 best solutions below