You are not logged in.

#1 2018-03-03 04:24:39

eichan
Member
Registered: 2018-01-08
Posts: 31

Strange issue with Apache? PHP? MySQL?

Hi everyone,

I need a hand troubleshooting a strange problem that may or may not be related to Arch Linux. It's after a long discussion on a PHP/MySQL IRC channel that I decided to come here and see if you guys would have an idea.

I'll try to keep it short: I have a web app running on an Amazon AWS server, written in PHP and using a DB (located on that same server). All good, works fine. My work laptop, on which I'm doing my dev work, is running Arch. I installed Apache2 and PHP 7.2.3, and am running the exact same app (simply copied from the GitLab repo I'm using), connecting to the same remote DB, and yet something is wrong. Most of my app works fine, communicating normally with the DB, but one feature simply fails to fetch data from the DB.

Here is the PHP function that works fine on my server, and on a work computer running Ubuntu, but not on my Arch laptop:

public function getSignoff($dateDay) {
        $query = $this->db->prepare('SELECT * FROM signoff WHERE dateDay = :dateDay');

        var_dump($query);

        if ($query->bindValue(':dateDay', $dateDay, PDO::PARAM_INT) === false) echo 'bindValue failed';
        if ($query->execute() === false) echo 'execute failed';
        if ($query->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Signoff') === false) echo 'setFetchMode failed';
        $signoff = $query->fetch();
        var_dump($signoff);
        echo "error: " . $query->errorCode();
        return $signoff;
    }

You'll notice that I amended my code to do some troubleshooting here. Turns out that it's simply fetch() that fails, $signoff is populated with bool(false) which I think means that the query worked, but found nothing in the DB. That's the part I don't get. I'm 200% sure there is something when using, for example, $dateDay = "2018-02-28", as the other instances of that app (again, exact same code, and exact same DB) work fine! The rest of the app works just fine.

Also, interestingly, here is a very similar function that calls the same DB but another table. And that one works fine on Arch:

public function getIssue($id) {
        $query = $this->db->prepare('SELECT * FROM issues WHERE id = :id');
        $query->bindValue(':id', $id, PDO::PARAM_INT);
        $query->execute();

        $query->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Issue');
        $issue = $query->fetch();
        return $issue;
    }

I've tested multiple times that I send the right $dateDay when I call getSignoff(). The call actually looks like that:

$signoff = $signoffManager->getSignoff($_GET['date']);

And yes, $_GET['date'] is correct on all instances. For a moment I thought it could have something to do with differences is date formats, but it doesn't seem so (both localhost URL and prod server URL show the same format for the GET value).

So yeah. I'm lost. Any ideas? I'm happy to provide any other logs/test results if needed.

Thanks!

Offline

Board footer

Powered by FluxBB