Tag Archives: error

JS: Prevent IE crash when using console (console.log)

Written by Garry Lachman (Admin). Filed under JavaScript. Tagged , , , , , , , , , , , . .

When the console is close and we call console.log from javascript most of the times
Internet Explorer will crash with the message:
Error: ‘console’ is undefined

Here is my solution for this annoying bug.

1
2
3
4
5
6
7
if (typeof console == 'undefined')   {
    var console = new Object();
    console.log = function(){}
    console.error = function(){}
    console.debug = function(){}
    console.warn = function(){}
}

Thanks “brucebannor” for advice.

Have fun :)
Garry Lachman

Share

“ereg is deprecated” warnings in PHP 5.3

Written by Garry Lachman (Admin). Filed under PHP + mySQL. Tagged , , , , , , , , , , , . .

If you try to install systems like OSCommerce on PHP 5.3.x you may got strange
error like “ereg is deprecated…”.

Here is the solution!!!

1
ereg('RegExp', $x $y);

becomes

1
preg_match('/RegExp/', $x $y);

dont forget “/ /” between the regexp code!!!

Same for “ereg_replace”

1
ereg_replace('RegExp', $x, $y);

becomes

1
preg_replace('/RegExp/', $x, $y);

Thanks,
Garry Lachman

Share