?
Solved

setlocale(LC_MONETARY, 'en_US'); not working on ubuntu 12.4

Posted on 2013-12-05
6
Medium Priority
?
1,095 Views
Last Modified: 2013-12-05
I have some php code displaying car prices. I'm using setlocale(LC_MONETARY, 'en_US'); to format the prices. Now this code works on my site hosted by Hostmonster, but on my ubuntu server this is not working. What could be the problem?

I forgot to add that this is not working either: money_format('%.0n' ,$row['InternetPrice']);
0
Comment
Question by:rraymond1130
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39698300
not working

Have you seen this link on the man page?
http://php.net/manual/en/function.money-format.php#86039

This also looks promising:
http://manpages.ubuntu.com/manpages/intrepid/man3/setlocale.3.html

Is there a symptom of failure that you might be able to share?  Is there a code example?  

Thanks, ~Ray
0
 

Author Comment

by:rraymond1130
ID: 39698330
Here is the code that is being used below. It works on the site hosted by hostmonster which is a Linux server. I figured it would work on a ubuntu server also since its Linux. No errors being reported:

setlocale(LC_MONETARY, 'en_US'); //Set Currency to US. This will put a $ in front of the number
$intPrice = money_format('%.0n' ,$row['InternetPrice']); //This sets the format for the dollar amount to $##,### no cents

I get a feeling their may be a package that needs to be installed on ubuntu but don't know which.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39698337
http://manpages.ubuntu.com/manpages/intrepid/man3/setlocale.3.html

I think you may need something like 'en_US.UTF-8' in setlocale()
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39698420
Testing on my server, both en_US and en_US.UTF-8 worked correctly.

<?php // RAY_temp_rraymond1130.php
error_reporting(E_ALL);
echo "<pre>";

// SEE http://www.experts-exchange.com/OS/Linux/Q_28311139.html

$x = setlocale(LC_MONETARY, 'en_US.UTF-8');
var_dump($x);

$row['InternetPrice'] = '1234.56';
$y = money_format('%.0n' ,$row['InternetPrice']);
var_dump($y);

Open in new window

0
 

Author Closing Comment

by:rraymond1130
ID: 39698422
As usual Ray, Great Help!!!! Thanks
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39698447
Thanks for the points and thanks for using EE! ~Ray
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question