Jump to content



Latest News: (loading..)

- - - - -

Warning: substr() expects parameter 3 to be long, string given in products_new.php on line 100

problem with php 5.3 & templa

  • Please log in to reply
5 replies to this topic

#1   djackson1001

djackson1001
  • Members
  • 2 posts
  • Real Name:Doug Jackson

Posted 11 June 2012 - 07:51 PM

I have several errors that show up on my site. This has happened recently due to I believe an update on the server (providers) to PHP 5.3

#2 ONLINE   DunWeb

DunWeb

    The Censored One

  • Members
  • 12,822 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Ontario, Canada

Posted 11 June 2012 - 08:14 PM

@djackson1001


You duplicate post in the commercial support area requests additional information.  THIS post, will also require additional information.  However, if the error was caused by a PHP update, I would suggest you update your website to be PHP 5.3 compatible.




Chris
:|: Was this post helpful ? Click the LIKE THIS button :|:

See my Profile to learn more about add ons, templates, support plans and custom coding (click here)

#3   germ

germ
  • Members
  • 13,921 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 11 June 2012 - 08:28 PM

View Postdjackson1001, on 11 June 2012 - 07:51 PM, said:

I have several errors that show up on my site. This has happened recently due to I believe an update on the server (providers) to PHP 5.3

All you have to do is force parameter 3 to be of the right "type" by putting (int) in front of it.

Edited by germ, 11 June 2012 - 08:29 PM.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#4   MrPhil

MrPhil
  • Members
  • 4,194 posts
  • Real Name:Phil
  • Gender:Male

Posted 14 June 2012 - 03:31 PM

View Postgerm, on 11 June 2012 - 08:28 PM, said:

All you have to do is force parameter 3 to be of the right "type" by putting (int) in front of it.

That's risky. The complaint is that the parameter is not a well-formed number. It doesn't matter if a well-formed number is in the form of a string -- PHP should convert it to an integer. It sounds like there is some other garbage in there. (int) may simply hide the problem by forcing non-numeric text to a 0. It would be better to find the source of the invalid data and fix it (upstream).

#5   germ

germ
  • Members
  • 13,921 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 14 June 2012 - 04:41 PM

View PostMrPhil, on 14 June 2012 - 03:31 PM, said:

That's risky. The complaint is that the parameter is not a well-formed number. It doesn't matter if a well-formed number is in the form of a string -- PHP should convert it to an integer. It sounds like there is some other garbage in there. (int) may simply hide the problem by forcing non-numeric text to a 0. It would be better to find the source of the invalid data and fix it (upstream).

Probably not. I can't say I've ever seen a case where doing this would be "risky", personally.

PHP does a pretty good job converting strings to numbers and vice versa when it needs to most of the time.

Other times it requires a little help.

But unless the OP bothers to come back and post the offending code we'll never know.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#6   EricK

EricK
  • Members
  • 313 posts
  • Real Name:Eric_K
  • Gender:Male
  • Location:Atlanta, GA USA

Posted 10 September 2012 - 10:31 PM

Thanks, Jim, applied your 'fix' to this code in a fork of osC.

   $p_desc = substr(strip_tags($product['products_description']), 0, (int)MAX_DESCR_1);

Cheers,
EricK