What causes: Notice: Uninitialized string offset to appear?
This error would occur if any of the following variables were actually strings or null instead of arrays, in which case accessing them with an array syntax $var[$i]
would be like trying to access a specific character in a string:
$catagory
$task
$fullText
$dueDate
$empId
In short, everything in your insert query.
Perhaps the $catagory
variable is misspelled?
Notice: Uninitialized string offset: 1
The problem is on this line:
if (in_array($word[$i].$word[$i+1],$letters)){
On the last iteration of the loop, $word[$i]
is the last character of $word
, and there is no $word[$i+1]
. You should change this to check that you're not at the end of the string:
if ($i < $len - 1 && in_array($word[$i].$word[$i+1],$letters)){
Trying to post array causes notice: Uninitialized string offset
You are indeed posting strings. You cant post arrays. You can first serialize the array to a string then unserialize it after the post.
change:
<td><?php echo "$navn";?><input type="hidden" name="historik[]" value="<?php echo "$navn";?>"></td>
To:
<td><?php echo "$navn";?><input type="hidden" name="historik[]" value="<?php echo base64_encode(serialize($navn));?>"></td>
Then in your loop:
foreach ($_POST['historik'] as $historikArray)
{
echo unserialize(base64_decode($historikArray))[3];
Notice: Uninitialized string offset:2
Where are the quotes?
$rs[CAT_ID], $rs[F_STATUS], $rs[F_SUBJECT]
try placing one :
$rs['CAT_ID'], $rs['F_STATUS'], $rs['F_SUBJECT']
php error reporting Uninitialized string offset: 0
For empty string, you can't use $sentence[0]
, that will cause the notice you got.
You can add !empty($sentence)
to check if it is empty.
Related Topics
Manipulate an Archive in Memory with PHP (Without Creating a Temporary File on Disk)
Jquery Mobile: How to Correctly Submit Form Data
Hide Shipping Methods for Specific Shipping Class in Woocommerce
How to Capture the Result of Var_Dump to a String
PHP Add Elements to Multidimensional Array with Array_Push
PHP Unserialize Fails with Non-Encoded Characters
Sharing Session Variables Between Multiple Subdomains
Why Doesn't File_Get_Contents Work
How to Count Days Between Two Dates in PHP
How to Call a PHP Script/Function on a HTML Button Click
How to Add a Delete Button to a PHP Form That Will Delete a Row from a MySQL Table
Is There a PHP Sandbox, Something Like Jsfiddle Is to Js
Email from PHP Has Broken Subject Header Encoding