General Community > Scripting Help

trouble with number after dollar sign

(1/2) > >>

Haase:
I noticed in a bunch of place that if some puts in a quantity such as $9.52, the display is not showing the $9.  I know I can do a something like this
--- Code: ---$articlec['heading'] = str_replace("\$", "$", $articlec['heading']);
--- End code ---
But I would have to pepper the entire code with this stuff.  Is there an easier way?

[Unknown]:
Are you evaluating the input?  That's a <?php echo 'bad';?> idea indeed.

-[Unknown]

Spaceman-Spiff:
use single quotes, so $ sign wont be parsed as a variable:
<?php echo '$9.25'; ?>
another way is to escape it when using double quotes:
<?php echo "\$9.25"; ?>

Haase:

--- Quote from: [Unknown] on September 27, 2003, 04:59:14 PM ---Are you evaluating the input?  That's a <?php echo 'bad';?> idea indeed.

-[Unknown]

--- End quote ---

I don't *think* so. 

The only thing I'm doing before inserting to the database is:
--- Code: ---   $_POST['heading'] = htmlspecialchars($_POST['heading']);
   $_POST['sub_heading'] = htmlspecialchars($_POST['sub_heading']);
--- End code ---

Then on view, I'm pulling this data from the database into an array, and I'm passing the array straight into my template engine.  Between the database and the output, I'm not manipulating that code at all, which is the way I'd like to keep it, but if I have to escape the dollar sign, I will.  It's just weird that this only occurs with numbers,  $9 won't show, but $a shows fine.

[Unknown]:
Strangely enough, I've found that anything in <title> cannot have $ signs.  I think it's something to do with Windows and not HTML.  I also think it's only IE.

The only other thing is if you are using it in a regular expression replace.  (is that how your template system works?)

-[Unknown]

Navigation

[0] Message Index

[#] Next page

Go to full version