lingo5 Posted June 8, 2011 Share Posted June 8, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/ Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 I will look into your problem shortly, however as a side note, i would recommened against using $PHP_SELF as your forms action, here's why Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1226945 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 thanks fugix for te advice on the <?php $PHP_SELF;?> stuff. I have now fixed all my code. Any ideas on the charset problem? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1226970 Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 i have read into this a little and have found a few websites that talk about a few issues that can be causing this..it is possible that your server may be overriding your charset...read this and let me know if it helps Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1226978 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1226992 Share on other sites More sharing options...
TeNDoLLA Posted June 8, 2011 Share Posted June 8, 2011 How about the editor you use to save the files? What charset does it use for saving? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227011 Share on other sites More sharing options...
xyph Posted June 8, 2011 Share Posted June 8, 2011 Use htmlentities() before passing the variables through the URL. If you're only echo'ing the data, you shouldn't need to use html_entity_decode() Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227025 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227034 Share on other sites More sharing options...
xyph Posted June 8, 2011 Share Posted June 8, 2011 echo htmlentities($row_clientes_RS['id_cliente']) Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227037 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 sorry xyph, wrong code. Here's how I pass the variable header("Location: EST_quotation_insert.php?company_name=$company_name"); Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227038 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 fugix how do I find that out? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227045 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 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???? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227058 Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 fugix how do I find that out? find what out? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227071 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 How about the editor you use to save the files? What charset does it use for saving? Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227072 Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 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))"); Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227076 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227079 Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227090 Share on other sites More sharing options...
lingo5 Posted June 8, 2011 Author Share Posted June 8, 2011 IE 9 is still a beta version. Hopefully they will fix this soon. Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227094 Share on other sites More sharing options...
fugix Posted June 8, 2011 Share Posted June 8, 2011 IE 9 is still a beta version. Hopefully they will fix this soon. hope so, if i were you i would send them a message in regards to this Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227101 Share on other sites More sharing options...
xyph Posted June 8, 2011 Share Posted June 8, 2011 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) ); Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227204 Share on other sites More sharing options...
lingo5 Posted June 9, 2011 Author Share Posted June 9, 2011 YESSSS!!!!....xyph thanks a lot. Thanks all!! Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227342 Share on other sites More sharing options...
fugix Posted June 9, 2011 Share Posted June 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227382 Share on other sites More sharing options...
xyph Posted June 9, 2011 Share Posted June 9, 2011 You had the function within the quotes Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227534 Share on other sites More sharing options...
fugix Posted June 9, 2011 Share Posted June 9, 2011 You had the function within the quotes ah, your right... Quote Link to comment https://forums.phpfreaks.com/topic/238778-help-with-charset/#findComment-1227538 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.