Cannot access offset of type string on string... WTF ?

Hello,

I have a PHP function (called via AJAX) that sends me this error message (Cannot access offset of type string on string) and I absolutely don't understand where it's coming from... Help!
Here’s the call to my function
 if ($flwprosp) { $result = flwprosp($flwprosp, $civilite, $iduser, $nrp, $tel, $mail, $nom, $prenom, $adresse, $cpostal,$ville, $where, $date, $comment, $nextact, $noway, $debug); } </code Here’s the data received <code php> Array ( [flwprosp] => 2151300759 [nrp] => 1 [civilite] => Mme [iduser] => baa9188a-0dd0-4f50-aaab-65e421cca195 [tel] => tel [mail] => mail [nom] => nom [prenom] => prenom [adresse] => address [cpostal] => 00000 [ville] => ville [where] => splae [date] => 23/06/12:00 [comment] => eer [nextact] => 5 [noway] => 1 [debug] => 1 ) 


And here’s my function
 function flwprosp($idplace, $civilite, $iduser, $nrp, $tel, $mail, $nom, $prenom, $adresse, $cpostal,$ville, $where, $date, $comment, $nextact, $noway, $debug) { echo " flwprosp($idplace, $civilite, $iduser, $nrp, $tel, $mail, $nom, $prenom, $adresse, $cpostal,$ville, $where, $date, $comment, $nextact, $noway, $debug)"; if ($noway==1) { $client['statut'] = 4; } if ($nrp==1) { $client['statut'] = 3; } else { $client['statut'] = 2; } if ($nrp = 1) { $nextact = 7; } //we update the property $table = "Annonces"; $where["idlbc"] = $idplace; $place["adresse"] = $adresse; $place["cpostal"] = $cpostal; $place["ville"] = $ville; \Models\Admin::update($place, $table, $where, "", $debug); } 


It tells me

flwprosp(2151300759, Mme, baa9188a-0dd0-4f50-aaab-65e421cca195, 1, tel, mail, nom, prenom, address, 00000,ville, splae, 23/06/12:00, eer, 5, 1, 1)
<br />
"Fatal error</b>: Uncaught TypeError: Cannot access offset of type string on string in /homepages/41/d736140878/htdocs/escalierb/admin/www/ajx/ajax.php:55"

And line 55 is this line
 $where["idlbc"] = $idplace; 

From what I understand, there’s a story about attempting to access an index of an array or something, but the value $idplace is 2151300759, so a plain integer... What am I missing????
Thank you in advance for your help, this is urgent for me...

Configuration: Macintosh / Firefox 99.0

4 answers

  1. Contributor
    Hello, the starting point would be to share your complete code.
    Please indicate the name of each file you share.

    What did you assign to
    $where
    before calling the function?
    Did you write this code?
    Are you testing it for the first time?
    1. Contributor
      What are you trying to do on line 55?
      What is this
      $where["idlbc"]
      ?

      Have you tried translating the error message?
      For me, it says "Cannot access an offset of type string on a string".
      This indicates that it is not allowed to use a string type index ("idlbc") on a string ($where).

      Isn't that clear?
  2. Well, I found my answer on my own, it's due to the update of my hosting which switched to php8, there are quite a few functions in my scripts that it doesn't like at all... ;-)
    So for those who have the same issue, the correct syntax is
     $where = ["list_id" => $idplace];
    1. Contributor
      To finish, what do you do with the $where parameter received by the function?
  3. Sorry, I can't find how to set the status to "Resolved", I keep struggling every time..
    1. Contributor
      To set to "resolved": the
      ...
      under the initial question.
  4. To respond to yg_be (thanks for your help!), yes I wrote this code, and I have used it hundreds of times. The only thing that has changed is the PHP version of my server... ;-)
    But here’s one problem solved, thanks anyway!