accents being replaced with garbage in text fields on forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • canajien@gmail.com

    accents being replaced with garbage in text fields on forms

    i have php form on an apache server that sends an email and stores in
    a mysql database once it is submitted

    when someone enters a name with an accent over a letter it mangles the
    text

    for example

    the user enters Montréal and the email i get ends up looking like
    Montréal, it also stores it in the database this way

    any ideas on what is happening here and how i can correct it?

    thanks

  • Michael Fesser

    #2
    Re: accents being replaced with garbage in text fields on forms

    ..oO(canajien@g mail.com)
    >i have php form on an apache server that sends an email and stores in
    >a mysql database once it is submitted
    >
    >when someone enters a name with an accent over a letter it mangles the
    >text
    >
    >for example
    >
    >the user enters Montréal and the email i get ends up looking like
    >Montréal, it also stores it in the database this way
    >
    >any ideas on what is happening here and how i can correct it?
    Something interprets UTF-8 encoded data as ISO-8859-1.
    What encoding do you use on your pages and in your database?

    Micha

    Comment

    • Captain Paralytic

      #3
      Re: accents being replaced with garbage in text fields on forms

      On 24 Sep, 17:00, "canaj...@gmail .com" <canaj...@gmail .comwrote:
      i have php form on an apache server that sends an email and stores in
      a mysql database once it is submitted
      >
      when someone enters a name with an accent over a letter it mangles the
      text
      >
      for example
      >
      the user enters Montréal and the email i get ends up looking like
      Montréal, it also stores it in the database this way
      >
      any ideas on what is happening here and how i can correct it?
      >
      thanks
      Try issuing SET NAMES UTF8 after connecting to the database, before
      running any other queries.

      Comment

      • Gordon

        #4
        Re: accents being replaced with garbage in text fields on forms

        On Sep 24, 5:00 pm, "canaj...@gmail .com" <canaj...@gmail .comwrote:
        i have php form on an apache server that sends an email and stores in
        a mysql database once it is submitted
        >
        when someone enters a name with an accent over a letter it mangles the
        text
        >
        for example
        >
        the user enters Montréal and the email i get ends up looking like
        Montréal, it also stores it in the database this way
        >
        any ideas on what is happening here and how i can correct it?
        >
        thanks
        This sounds like a character encoding mismatch between the database
        and the HTMl pages. The most usual cause is the web page being
        encoded as iso-8859-1 (which I believe is the default format for
        Dreamweaver), and the database being in UTF-8, but any character
        encoding mismatch will produce similar results. Make sure that both
        your database and web pages are using the same encoding, these days
        this generally should be UTF-8.

        UTF-8 is the preferred encoding because a valid ASCII string is also a
        valid UTF-8 string, giving good backward compatibility. It also
        supports the full set of Latin alphabet accents and characters in a
        uniform way, and will even support far eastern languages (albeit in a
        way that's quite inefficient).

        Comment

        • canajien@gmail.com

          #5
          Re: accents being replaced with garbage in text fields on forms

          On Sep 25, 6:28 am, Gordon <gordon.mc...@n tlworld.comwrot e:
          On Sep 24, 5:00 pm, "canaj...@gmail .com" <canaj...@gmail .comwrote:
          >
          i have php form on an apache server that sends an email and stores in
          a mysql database once it is submitted
          >
          when someone enters a name with an accent over a letter it mangles the
          text
          >
          for example
          >
          the user enters Montréal and the email i get ends up looking like
          Montréal, it also stores it in the database this way
          >
          any ideas on what is happening here and how i can correct it?
          >
          thanks
          >
          This sounds like a character encoding mismatch between the database
          and the HTMl pages.  The most usual cause is the web pagebeing
          encoded as iso-8859-1 (which I believe is the default format for
          Dreamweaver), and the databasebeingin UTF-8, but any character
          encoding mismatch will produce similar results.  Make sure that both
          your database and web pages are using the same encoding, these days
          this generally should be UTF-8.
          >
          UTF-8 is the preferred encoding because a valid ASCII string is also a
          valid UTF-8 string, giving good backward compatibility.  It also
          supports the full set of Latin alphabetaccents and characters in a
          uniform way, and will even support far eastern languages (albeit in a
          way that's quite inefficient).
          thanks for the lesson guys :)

          the page was already set to utf-8 in a meta tag, so I added the
          following to the form tag:

          accept-charset="utf-8"

          for good measure I made sure the mysql table would accept the
          characters by resetting the table with:

          ALTER TABLE tablename DEFAULT CHARACTER SET utf8

          hopefully this will take care of my problem

          Comment

          • canajien@gmail.com

            #6
            Re: accents being replaced with garbage in text fields on forms

            unfortunately the changes i made weren't enough to correct my problem,
            however I did come across this page:



            and once I made the changes to my php.ini everything started working

            thanks again for the advise


            Comment

            Working...