Page 1 of 1

Using variable in string - Trying to access array offset on value of type bool

Posted: Sun Jan 22, 2023 5:32 pm
by apis

Hi, when i execute the bellow co i am getting an error like this:

Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\vote\models\DhaairaaList.php on line 3174

// Row Custom Action event
function Row_CustomAction($action, $row)
{
if ($action == "updat" ){
$ibu_vote_reporting = ExecuteRow("SELECT * FROM votereporting WHERE id = (SELECT MAX(id) FROM votereporting WHERE Island = '".$row["Island"]."' && DhaairaCode = '".$row["DhaairaCode"]."')");
$ibu_vote_rep_update = ExecuteStatement("UPDATE dhaairaa SET Ibu = '$ibu_vote_reporting[Ibu]', No = '$ibu_vote_reporting[No]' WHERE Island = '".$row["Island"]."' && DhaairaCode = '".$row["DhaairaCode"]."'");
$this->setSuccessMessage("Updated");  
 return true;
}
}

can you pls. let me know what the error is.


Re: Trying to access array offset on value of type bool

Posted: Sun Jan 22, 2023 6:04 pm
by mobhar

Try to echo or output the SQL before using it in that Row_CustomAction. Make sure the SQL is working properly. In addition, try to output all the variables in that event to make sure it should work when it is supplied into your SQL.


Re: Using result of ExecuteRow() - Trying to access array offset on value of type bool

Posted: Sun Jan 22, 2023 6:19 pm
by arbei

apis wrote:

$ibu_vote_rep_update = ExecuteStatement("UPDATE dhaairaa SET Ibu = '$ibu_vote_reporting[Ibu]', No = '$ibu_vote_reporting[No]' WHERE Island = '".$row["Island"]."' && DhaairaCode = '".$row["DhaairaCode"]."'");

The '$ibu_vote_reporting[Ibu]' and '$ibu_vote_reporting[No]' are wrong code. To avoid syntax error, you better use string concatenation instead of using variable inside double quoted string in this case.


Re: Using variable in string - Trying to access array offset on value of type bool

Posted: Sun Jan 22, 2023 8:11 pm
by apis

Thank you

the code works and updates the desired table, even though the error is thrown.