What Causes: "Notice: Uninitialized String Offset" to Appear

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



Leave a reply



Submit