I have this php case executed when called by a function in my main page. When I type my variables like this: $tutorReasonString = "I'm fine and working." and $clientReasonString = "I'm fine too, thanks for asking", nothing is wrong here. But when I try to fetch them with pg_fetch_array(), I get NULL values returned.
Note that tutorabsence and clientabsence tables are not connected with any kind of SQL trigger, I only assign them exact same id in another execution which is retrieved from a row of another table with php.
case "absencePc":
$id = array_search(post("id"), $_SESSION["keyhash"]);
$tutorAbsSql = "SELECT reason FROM tutorabsence WHERE id='$id'";
$tutorReason = pg_query($tutorAbsSql);
if(pg_fetch_row($tutorReason) == NULL) {
$tutorStatus = "0";
$tutorReasonString = "";
} else {
$tutorStatus = "1";
// $tutorReasonString = "I'm working"; This works
// This returns null.
$tutorReasonFetch = pg_fetch_array($tutorReason);
$tutorReasonString = $tutorReasonFetch["reason"];
};
$clientAbsSql = "SELECT reason FROM clientabsence WHERE id='$id'";
$clientReason = pg_query($clientAbsSql);
if(pg_fetch_row($clientReason) == NULL) {
$clientStatus = "0";
$clientReasonString = "";
} else {
$clientStatus = "1";
// $clientReasonString = "I'm working"; This works
// This returns null.
$clientReasonFetch = pg_fetch_array($clientReason);
$clientReasonString = $clientReasonFetch["reason"];
};
$response[] = array("tutorReason" => $tutorReasonString,
"clientReason" => $clientReasonString,
"tutorStatus" => $tutorStatus,
"clientStatus" => $clientStatus);
echo json_encode($response);
break;
reasonper$id, or is it just one?