I’m having problem acessing a JSON element after a sqlite query.
I have the following code:
$queryIdClient = "SELECT seq FROM sqlite_sequence WHERE name = 'clientes';";
$id;
if($result = $db->query($queryIdClient)) {
$row = $result->fetch(PDO::FETCH_ASSOC);
$row = json_encode($row);
echo $row;
}
else {
die($error);
}
The echo $row gives me {“seq” : “10”}.
I want to pass the value 10 to the $id variable. I’ve tried a lot of ways, but I can’t get it to work.
Shouldn’t it work with $id = $row->seq; ?
There’s no need for the json_encode() there: