functions.inc.php (Bugs)

by D-Grund Nyheder ⌂ @, Danmark, Thursday, October 28, 2010, 10:18 (4921 days ago)
edited by D-Grund Nyheder, Thursday, October 28, 2010, 10:24

Fixed a bug in "/forum/includes/functions.inc.php" on line 2147 and 2186

Code snippets from: "/forum/includes/functions.inc.php" line 2143 to 2153 on error line 2147
Original code from mylittleforum

function my_strlen($string, $encoding='utf-8')
 {
  if(function_exists('mb_strlen'))
   {
    return mb_strlen($string, $encoding);
   }
  else
   {
    return strlen($string);
   }
 }

change to

function my_strlen($string, $encoding='utf-8')
 {
  if(function_exists('mb_strlen'))
   {
    return @mb_strlen($string, $encoding);
   }
  else
   {
    return strlen($string);
   }
 }


End of code snippets from: "/forum/includes/functions.inc.php" line 2143 to 2153 on error line 2147

Code snippets from: "/forum/includes/functions.inc.php" line 2182 to 2192 on error line 2186
Original code from mylittleforum

function my_substr($string, $start, $length, $encoding='utf-8')
 {
  if(function_exists('mb_substr'))
   {
    return mb_substr($string, $start, $length, $encoding);
   }
  else
   {
    return substr($string, $start, $length);
   }
 }

change to

function my_substr($string, $start, $length, $encoding='utf-8')
 {
  if(function_exists('mb_substr'))
   {
    return @mb_substr($string, $start, $length, $encoding);
   }
  else
   {
    return substr($string, $start, $length);
   }
 }


Ends of code snippets from: "/forum/includes/functions.inc.php" line 2182 to 2192 on error line 2186

if not a warning(s) is displayet on top of the forum "Not good"

Hope it helps [image]

Avatar

functions.inc.php

by Auge ⌂, Thursday, October 28, 2010, 10:30 (4921 days ago) @ D-Grund Nyheder

Hello

Fixed a bug in "/forum/includes/functions.inc.php"

Code snippets from: "/forum/includes/functions.inc.php" line 2143 to 2153 on error line 2147

change to

function my_strlen($string, $encoding='utf-8')
 {
  if(function_exists('mb_strlen'))
   {
    return @mb_strlen($string, $encoding);
   }
  else
   {
    return strlen($string);
   }
 }


if not a warning(s) is displayet on top of the forum "Not good"

The function gets a string and the encoding. In wich using scenario there could popup a warning? Any examples?

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

functions.inc.php

by D-Grund Nyheder, Thursday, October 28, 2010, 11:59 (4920 days ago) @ Auge
edited by D-Grund Nyheder, Thursday, October 28, 2010, 12:06

Hello

Fixed a bug in "/forum/includes/functions.inc.php"

Code snippets from: "/forum/includes/functions.inc.php" line 2143 to 2153 on error line 2147

change to

function my_strlen($string, $encoding='utf-8')
{
if(function_exists('mb_strlen'))
{
return @mb_strlen($string, $encoding);
}
else
{
return strlen($string);
}
}


if not a warning(s) is displayet on top of the forum "Not good"


The function gets a string and the encoding. In wich using scenario there could popup a warning? Any examples?

Tschö, Auge

Hello Auge

I get the warning when I will see what is posted in the forum (Warning: mb_substr () [function.mb-substr]: Unknown encoding "" in /****/********/ public_html / forum / includes / functions.inc.php on line 2186)

When I want to see user settings (Warning: mb_substr () [function.mb-substr]: Unknown encoding "" in /****/********/ public_html / forum / includes / functions.inc. php on line 2186

Warning: mb_strlen () [function.mb-strlen]: Unknown encoding "" in /****/********/ public_html / forum / includes / functions.inc.php on line 2147

Warning: mb_substr () [function.mb-substr]: Unknown encoding "" in /****/********/ public_html / forum / includes / functions.inc.php on line 2186)

But I put an @ in front as shown in previous postings

It works for me.

Avatar

functions.inc.php

by Auge ⌂, Thursday, October 28, 2010, 15:50 (4920 days ago) @ D-Grund Nyheder

Hello

Fixed a bug in "/forum/includes/functions.inc.php"

Code snippets from: "/forum/includes/functions.inc.php" line 2143 to 2153 on error line 2147

change to

function my_strlen($string, $encoding='utf-8')
 {
  if(function_exists('mb_strlen'))
   {
    return @mb_strlen($string, $encoding);
   }
  else
   {
    return strlen($string);
   }
 }


if not a warning(s) is displayet on top of the forum "Not good"


The function gets a string and the encoding. In wich using scenario there could popup a warning? Any examples?


I get the warning when I will see what is posted in the forum (Warning: mb_substr () [function.mb-substr]: Unknown encoding "" in /****/********/ public_html / forum / includes / functions.inc.php on line 2186)

When I want to see user settings (Warning: mb_substr () [function.mb-substr]: Unknown encoding "" in /****/********/ public_html / forum / includes / functions.inc. php on line 2186

That seems to be a bug. The function mb_substr is called inside my_substr where an encoding is declared ($encoding='utf-8'). It can't be empty, except you give an empty encoding declaration to my_substr.

$substring = my_substr($string, '');

There must be anything else ...

But I put an @ in front as shown in previous postings

That's not a bug fix. It covers the bug instead to correct it.

It works for me.

not really (see above) ;-)

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

functions.inc.php

by D-Grund Nyheder, Sunday, October 31, 2010, 22:38 (4917 days ago) @ Auge

yes but i have it running and don´t wont to have it show errors and the forum is working.

but that the only info about the error.

off course did i not solved the error only suppressed the warnings. sorry [image]

Avatar

functions.inc.php

by Micha ⌂, Monday, November 01, 2010, 10:29 (4917 days ago) @ Auge

Hello,

except you give an empty encoding declaration to my_substr.

$substring = my_substr($string, '');

Isn't it possible to check the $encoding variable inside the function like?

function my_strlen($string, $encoding='utf-8') {
   if(function_exists('mb_strlen')) 
     return mb_strlen($string, empty($encoding)?"utf-8":$encoding);
   else
     return strlen($string);
}


regards Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

functions.inc.php

by Auge ⌂, Monday, November 01, 2010, 11:45 (4916 days ago) @ Micha

Hello

except you give an empty encoding declaration to my_substr.

$substring = my_substr($string, '');


Isn't it possible to check the $encoding variable inside the function like?

function my_strlen($string, $encoding='utf-8') {
if(function_exists('mb_strlen')) 
return mb_strlen($string, empty($encoding)?"utf-8":$encoding);
else
return strlen($string);
}

Arrgh! a complete if-else-switch inside a function call. That is to much "JavaScript stylish" for me. ;-)

Yes it is possible to check $encoding for emptyness. But why? If you don't set a different encoding in the many many function calls there is a value for $encoding inside my_strlen.

So there is only one question: Why gets D-Grund Nyheder the error message(s)?

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

functions.inc.php

by Micha ⌂, Monday, November 01, 2010, 21:34 (4916 days ago) @ Auge

Hi Auge,

Arrgh! a complete if-else-switch inside a function call. That is to much "JavaScript stylish" for me. ;-)

Okay, I keep calm :-D

regards
Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

functions.inc.php

by D-Grund Nyheder, Tuesday, November 02, 2010, 20:54 (4915 days ago) @ Auge
edited by D-Grund Nyheder, Tuesday, November 02, 2010, 21:41

witch format of mysql ?

functions.inc.php

by D-Grund Nyheder, Tuesday, November 02, 2010, 22:07 (4915 days ago) @ D-Grund Nyheder
edited by D-Grund Nyheder, Tuesday, November 02, 2010, 22:43

 
function my_strlen($string,$encoding='utf-8'){ 
 if(function_exists('mb_strlen')){
  if(empty($encoding)){
   $encoding='utf-8';
  }
  return mb_strlen($string,$encoding);
 }else{
  return strlen($string);
 }
}

i will do this to use default if empty like the function is made in ($string,$encoding='utf-8')

I have done this on all functions with the $encoding in. and a much better solution.
and it works.

so @ solution was a panic solution and this seams to really work without errors and no suppressing the errors there are no errors at all. but so the missing $encoding.

i will be back.

functions.inc.php

by D-Grund Nyheder, Wednesday, November 03, 2010, 21:34 (4914 days ago) @ D-Grund Nyheder
edited by D-Grund Nyheder, Wednesday, November 03, 2010, 22:19

Hello
I would ask if there are others who have a suggestion for where the empty $encoding will be granted or where it goes wrong?

in index.php is a functions call where this $lang['charset'] is used for feeding $encoding
Sorry for my bad English.

LAT [image]

RSS Feed of thread