Accessibility Specialist. I focus on ensuring content created, events held and company assets are as accessible as possible, for as many people as possible.
There appears to be bits missing here (try reformatting your post) - you are initially adding everything to an array $rows.
But what I can't see is where you then iterate over those rows using something like
foreach($rowsas$row){// within the loop now so we can access each $row.}
That might be where your mistake lies.
Illegal String Offset errors in circumstances like this are when you try to access a property that does not exist in an array (or more specifically that you have a string and are trying to access an array property on it).
If you aren't within a loop you are essentially trying to access $row when it is technically undefined, so it converts it to a string thinking it is a new variable and then tries to find the element at position "content", which doesn't exist.
Sorry if that makes it sound complicated and I don't think I explained it well, but in essence $row is not an array at the point you are trying to use it.
The code is exactly as shown on the instructions I am following, so I have no idea how they get the results shown. I will figure out how to do this. As the result will show the number of messages above the messages. So if there are three messages this will be a number.
Not long after posting the reply, I looked carefully at the code on the video and mine, and it turns out I had made a mistake. I had $rows = $row;, which should have been $rows[] = $row;. Once I corrected this, the results I got matched the video. In the words of a wise man "Doh!"
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There appears to be bits missing here (try reformatting your post) - you are initially adding everything to an array
$rows.But what I can't see is where you then iterate over those rows using something like
That might be where your mistake lies.
Illegal String Offseterrors in circumstances like this are when you try to access a property that does not exist in an array (or more specifically that you have a string and are trying to access an array property on it).If you aren't within a loop you are essentially trying to access
$rowwhen it is technicallyundefined, so it converts it to a string thinking it is a new variable and then tries to find the element at position "content", which doesn't exist.Sorry if that makes it sound complicated and I don't think I explained it well, but in essence
$rowis not an array at the point you are trying to use it.The code is exactly as shown on the instructions I am following, so I have no idea how they get the results shown. I will figure out how to do this. As the result will show the number of messages above the messages. So if there are three messages this will be a number.
Not long after posting the reply, I looked carefully at the code on the video and mine, and it turns out I had made a mistake. I had $rows = $row;, which should have been $rows[] = $row;. Once I corrected this, the results I got matched the video. In the words of a wise man "Doh!"