1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What is wrong?

Discussion in 'PHP' started by kc3, May 30, 2005.

  1. #1
    For some reason if I take this code out my script works just fine just not formatted as a price. Well, I have nearly this exact code ( just different variables ) in another script and it works just fine. I was wondering if I did something wrong, all it says is "called to un-defined function money_format()". This is a standard function and should work just fine but if I use this code it doesn't work.

    Code-
    settype ( $price, "double" );
    $price = money_format( '%i', $price );
     
    kc3, May 30, 2005 IP
  2. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #2
    From the documentation:

     
    mnemtsas, May 30, 2005 IP
  3. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But I'm on a FreeBSD server. Does FreeBSD not have strfmon capabilities?
     
    kc3, May 30, 2005 IP
  4. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I suspected you were testing on your local PC before uploading it and you were seeing the error there. Clearly I was wrong :D
     
    mnemtsas, May 30, 2005 IP
  5. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No, I used it on the server. Does FreeBSD not have the capability?
    I made a special testing area on my website since I many times use multiple computers and I'm on one that isn't a server, if I make changes I just make a note of it and re-back up my website's files so I have them in a convenient place.
     
    kc3, May 30, 2005 IP
  6. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What version of php is installed?
     
    mnemtsas, May 30, 2005 IP
  7. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's 4.3.10, not the newest but should be able to have the money_format function. At least according to the php.net documentation.
     
    kc3, May 30, 2005 IP
  8. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hmmm, ok let me post a test file to one of my hosts and see what it does there.

    Funnily enough it doesn't work on my server either :(
     
    mnemtsas, May 30, 2005 IP
  9. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Sure, and thanks for all the help. I wonder what it could be. Doesn't it work on php4.3.10?
     
    kc3, May 30, 2005 IP
  10. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #10
    It should work on 4.3.10 +, but doesn't work on any of the three hosting companies I use.
     
    mnemtsas, May 30, 2005 IP
  11. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Have you tried using "number_format()" it can do the same job.
     
    mushroom, May 31, 2005 IP
  12. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Perhaps they made a mistake in the documentation.

    Yeah but if the price's last digit after the decimal is 0 it just drops it. Is there another alternative?
     
    kc3, May 31, 2005 IP
  13. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Why not explode the string after using number_format:

    
      $number="$1.2"
      list($dollars,$cents)=explode(".",$number);
      if (strlen($cents)==1)
        $cents.=$cents."0";
      if (strlen($cents)==0)
        $cents="00";
      $number=$dollars.".".$cents;
    
    Code (markup):
     
    mnemtsas, May 31, 2005 IP
  14. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Are you using number_format($var,2);

    It works for me $var="123" or $var="123.001" both display as 123.00
     
    mushroom, May 31, 2005 IP