5

I am newbie in PHP. A PHP was migrated today from 5.3.3 to 5.4.4 version (Debian Squeeze to Debian Wheezy) and, after this, I get this error from Apache log :

> PHP Warning: Illegal string offset 'phptype' in xyz

The line is:

self::$conn[$dsn['phptype']] = $mdb2;

I need help to restore the system.

KRUNAL DOSHI
  • 81
  • 1
  • 2
  • 10
Eriberto Mota
  • 81
  • 1
  • 1
  • 3

2 Answers2

4
<?php
$a = 'Hello';
echo $a['whatever'];
?>

As some of the guys in the comments are saying, doing something like this would probably cause that error. As you can see in the example above $a is a string rather than an array. This means that you cannot access it with a key (if however you wanted to get the 3rd letter in the string it would be ok to do $a[2]).

You need to check that self::$conn and $dsn are actually arrays rather than strings. As Álvaro G. Vicario says in the comments, you can do this by dumping the variable:

var_dump(self::$conn, $dsn)

OdinX
  • 4,135
  • 1
  • 24
  • 33
0

Illegal offset type errors occur when you attempt to access an array index using an object or an array as the index key. Check whether your array is proper.

chandresh_cool
  • 11,753
  • 3
  • 30
  • 45