Fatal Error: [] Operator Not Supported for Strings
In this error instance, you encountered the "Fatal error: [] operator not supported for strings" when attempting to save updated information to your database. The issue stems from a programming practice known as the "empty-index" array push syntax, which is typically used to create a new array or add entries to an existing one.
In your code, you're using the [] operator on variables ($name, $date, $text, and $date2) that are initialized as strings. PHP 7 has enforced stricter controls around this syntax, prohibiting its use on variables declared as strings, numbers, objects, etc.
To resolve this error, modify your code as follows to assign values directly to the variables instead of using the "empty-index" push syntax:
$name = $row['name'];
$date = $row['date'];
$text = $row['text'];
$date2 = $row['date2'];
Alternatively, if you intended to create arrays, you could initialize them as empty arrays and then use the [] push syntax:
$name = [];
$name[] = $row['name'];
$date = [];
$date[] = $row['date'];
$text = [];
$text[] = $row['text'];
$date2 = [];
$date2[] = $row['date2'];
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3