Fork me on GitHub

$ sign problem - please advise.  Bottom

  • I'm a newbie trying to write a short PHP script within PostNuke to enter data into a MySQL database.

    If I enter something like "Please pay $20 now" into a simple text field, the dollar sign and the figure are missed out - this means that only "Please pay now" is saved.

    This is an example of the output:

    1.2 dollars = .2
    1.20000 dollars = .20000
    1.22222 dollars = .22222
    12.33333 dollars = .33333
    123.44444 dollars = 3.44444
    1234.55555 dollars = 34.55555
    12345.66666 dollars = 345.66666

    (of course, no $ sign - or the first two numbers - are saved in the MySQL database).

    Could one of you tell me what a possible solution could be. Ie. is this an escape character in PHP or MySQL? and if so, do you have a possible solution?


    Please forgive my dumness, this may be painfully obvious to some of you.
  • If you use double quotes PHP interprets the $20 as an variable and replaces it with its content - which is empty in your case.

    Use single quotes instead. So the $20 remains as is.

    Frank

    --
    "He is not dangerous, he just wants to play...."
  • Thanks Frank :)

This list is based on users active over the last 60 minutes.