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

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
apis
User
Posts: 124

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

Post 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.


mobhar
User
Posts: 11660

Post 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.


arbei
User
Posts: 9286

Post 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.


apis
User
Posts: 124

Post by apis »

Thank you

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


Post Reply