Jump to content

Help with charset


lingo5

Recommended Posts

Hi, I am building a website in Spanish and I use charset=iso-8859-1 in all the pages and it works fine everywhere except for one page where accents are displayed as "?" when displaying a variable that has been passed from another page. I`ve tried everything, changing to different charsets etc...but no luck.

This is the code for the page where accents are not displaying correctly:

 

$companyname = $_GET['company_name'];  //this  the variable that gets the value from the previous page

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="es"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<link href="../CP_estilos/extranet_styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php include('EST_header.php'); ?>
<form action="<?php $PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="850" border="0" align="center" cellpadding="8" cellspacing="0">
    <tr>
      <td><table width="100%" border="0" cellspacing="0" cellpadding="10">
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
            <tr>
              <td><span class="CP_blueTXT">Presupuesto para <span class="CP_errorLoginTxt"><?php echo (isset($_GET['facturainserted']))?'<p>Factura insertada correctamente</p>':''; ?></span></span></td>
            </tr>
            <tr>
              <td class="personalTitulo" charset="iso-8859-1"><?=$companyname?> // tis is the variable that displays text with no accents
                <input name="id_cliente" type="hidden" id="id_cliente" value="<?php echo $row_clientes_RS['id_cliente']; ?>" />
                <input name="cliente_email" type="hidden" id="cliente_email" value="<?php echo $row_clientes_RS['cliente_email']; ?>" /></td>
            </tr>
          </table></td>
        </tr>
      </table>
        <table width="100%" border="0" cellpadding="10" cellspacing="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td width="25%"><span class="CP_blueTXT">Fecha presupuesto</span></td>
                <td width="75%"><span class="CP_blueTXT">Nº presupuesto</span></td>
              </tr>
              <tr>
                <td><input name="quotation_date" type="text" class="CP_loginFormFields" id="quotation_date" value="" size="32" /></td>
                <td><input name="quotation_number" type="text" class="CP_loginFormFields" id="quotation_number" value="" size="32" /></td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td><span class="CP_blueTXT">Título presupuesto</span></td>
              </tr>
              <tr>
                <td><input name="quotation_title" type="text" class="CP_loginFormFields" id="quotation_title" value="" size="70" /></td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td> </td>
              </tr>
              <tr>
                <td> </td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td> </td>
              </tr>
              <tr>
                <td> </td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td width="2%"> </td>
                <td width="98%"><input name="upload" type="submit" id="upload" value="guardar presupuesto" />                  <input type="hidden" name="MM_insert" value="form1" /></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
</body>
</html>

Link to comment
Share on other sites

Hi fugix,

I have read the document you sent me and yes, my browser is set to the correct charset and I don't think the server is messing with the charset as other pages show accenta ok. It is just this page where I get the $companyname variable from the previous page. Could it be because I pass the variable in the URL?

Link to comment
Share on other sites

Hi Xyph,

sorry I don't know what you mean. This is how I pass the variable

<tr>
              <td class="personalTitulo" ><?=$companyname?>
                <input name="id_cliente" type="hidden" id="id_cliente" value="<?php echo $row_clientes_RS['id_cliente']; ?>" />
                <input name="cliente_email" type="hidden" id="cliente_email" value="<?php echo $row_clientes_RS['cliente_email']; ?>" /></td>
            </tr>

Link to comment
Share on other sites

OK, this is what i've found out:

 

I pass the variable after executing the record insert query like this:

header("Location: EST_quotation_insert.php?company_name=$company_name");

I have noticed that the URL showing on my browser looks like this:

http://localhost/admin/EST_quotation_insert.php?company_name=Alba Comunicaci�n

notice the weird character instead of the accent (should read Comunicación).

Now, if I manually fix that on my browser, the accent shows fine on the page.

Why is the variable

company_name=$company_name");

being messed up????

Link to comment
Share on other sites

How about the editor you use to save the files? What charset does it use for saving?

well im not sure what editor you are using, however there should be an option in the edito options showing the default charset and how to change it...also, i think your var may be displaying strange characters because you have not prepped it to pass through the url. try

header("Location: EST_quotation_insert.php?company_name=urlencode($company_name)");

or even one step further

header("Location: EST_quotation_insert.php?company_name=htmlentities(urlencode($company_name))");

Link to comment
Share on other sites

oh well....I think I've found the problem. The page displays fine on Firefox and IE8. I am using IE9 at the moment and that seems to be the problem.

 

Thankyou all for your help.

glad you found the solution, however you will want to make sure that people using ie9 are able to view the page correctly as well.

Link to comment
Share on other sites

IE9 isn't automatically URL Encoding the special characters for you.

 

Try using this

 

header("Location: EST_quotation_insert.php?company_name=" . rawurlencode($company_name) );

i posted something very similar before, however im glad it worked for you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.