I need help with a PHP script!

Discussion in 'PHP' started by Stefan, Jun 9, 2006.

  1. #1
    Hey there. I have this image hosting and watermarking script. When I uploaded it to my server it get this error:

    Fatal error: Call to undefined function: str_ireplace() in /home/content/C/y/b/CyberSite/html/skumbucket/img/libs/setup.php on line 48
    Code (markup):
    If I send somebody the file that's being messed up can somebody fix it, or tell me what to do?
     
    Stefan, Jun 9, 2006 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Can you post the code around line 48 in setup.php?
     
    jestep, Jun 9, 2006 IP
  3. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #3
    str_ireplace() is a PHP5 function only. So your script was written for PHP 5 but the server is (smartly) running a 4 version.

    You can replace the function calls with eregi_replace
     
    TheHoff, Jun 9, 2006 IP
  4. infin8

    infin8 Peon

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah, most hosts run php 4 anyway.
     
    infin8, Jun 9, 2006 IP
  5. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Or if your server plans to upgrade to PHP5 shortly you could just stick in at the bottom of your page

    function str_ireplace($string_pattern, $string_replacement, $string_string){
    return eregi_replace($string_pattern, $string_replacement, $string_string);
    }


    and when you upgrade just remove the code.
     
    Weirfire, Jun 9, 2006 IP
  6. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ^^^ ooh weirfire, efficient coding machine... nice solution
     
    TheHoff, Jun 9, 2006 IP
  7. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Thanks Hoff. 80 hours work a week forces you to be efficient lol.
     
    Weirfire, Jun 9, 2006 IP
  8. Stefan

    Stefan Well-Known Member

    Messages:
    787
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #8
    Tried all your solutions. The one Weirfire gave me, gave me even more errors.
     
    Stefan, Jun 9, 2006 IP
  9. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well we all suck. It helps to post the exact error.
     
    TheHoff, Jun 9, 2006 IP
  10. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #10
    lol

    Its probably something to do with the format of the parameters. It wouldn't take a PHP genius or much research time to figure out which way its supposed to be structured. eregi_replace has a slightly different method of taking in the parameters as it uses patterns and not strings.

    So the adjusted function would be

    function str_ireplace($string_pattern, $string_replacement, $string_string){

    $pattern = "(".$string_pattern.")";
    $replacement = $string_replacement;
    $string = $string_string;

    return eregi_replace($pattern, $string_replacement, $string);
    }

    I have no idea what your code looks like or what you're trying to do. Now go do some of your own programming and don't go on about how someones solution gave a bunch of errors when you hadn't even tried sorting it yourself.
     
    Weirfire, Jun 10, 2006 IP
  11. Stefan

    Stefan Well-Known Member

    Messages:
    787
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #11
    Well thing is I don't know PHP at all. Only xHTML and CSS.
     
    Stefan, Jun 10, 2006 IP
  12. Chemo

    Chemo Peon

    Messages:
    146
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Just because you haven't seen his code and he obviously does not have the ability to research and correct his own problem does't mean you can't do the work for him (free of charge). Further, you should always be subject to the cries of "it doesn't work" when offering good coding practice of encapsulating.

    I hope you didn't miss the sarcasm... :)

    Bobby
     
    Chemo, Jun 10, 2006 IP
  13. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #13
    But why should that stop you from posting the code on your page. That's all anyone was asking for to try and help solve your problem. Anyway, I've tested the latter solution and I know that it works so that should help you out for now until you get a server upgrade.

    lol Bobby. Sorry for leaving out the commenting as well. :p
     
    Weirfire, Jun 12, 2006 IP