Solved

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

Posted on 2013-12-05
6
976 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
  • 4
  • 2
6 Comments
 
LVL 108

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 108

Accepted Solution

by:
Ray Paseur earned 500 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 108

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 108

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now