Problem with: Fatal error: [] operator not supported for strings in Ask Question
![Problem with: Fatal error: [] operator not supported for strings in Ask Question](/files/public/img/noimage.gif)
I\'m getting information from database, saving it in array and echoing it in a form with loop structure and I\'m having problems when I try to save the modified information to database. I\'m getting this error: Fatal error: [] operator not supported for strings in....
<p>You get this error when attempting to use the short array push syntax on a string.</p>
<p>For example, this</p>
<pre>
<code>foo = 'foo';foo[] = 'bar'; // ERROR!</code></pre>
<p>I'd hazard a guess that one or more of your <code>name</code>, <code>date</code>, <code>text</code> or <code>date2</code> variables has been initialised as a string.</p>
<p><strong>Edit:</strong> Looking again at your question, it looks like you don't actually want to use them as arrays as you're treating them as strings further down.</p>
<p>If so, change your assignments to</p>
<pre>
<code>row['name'];
row['date'];
row['text'];
row['date2'];</code></pre>
评论 (0)
加载评论中…