Re: [PHP] Problem when adding special characters to an XML file
Hi again, Now I download the editing XML file and open it in windows with notepad and save with utf-8 encode, then upload the file again and can see the correct characters, what's the problem? I'm specifying the correct encoding when process the form and editing the XML file: $XML = new DOMDocument('1.0', 'UTF-8'); Any idea please... Thanks, te0
Re: [PHP] Problem when adding special characters to an XML file
Thanks for your offer Richard, but I solved the problem deleting the UTF-8 encoding label in the XML file like this: before: ?xml version=1.0 encoding=utf-8? label/label after: ?xml version=1.0?
[PHP] Problem when adding special characters to an XML file
Hi, I'm editing an XML file through a form: $XML = new DOMDocument('1.0', 'UTF-8'); $XML-preserveWhiteSpace = false; $XML-load(../xml/exposiciones.xml); $raiz = $XML-documentElement; $nodoContenedor = $XML-getElementsByTagName('texto'); foreach ($nodoContenedor as $NuevoNodo) { //titulo $nodoTitulo = $XML-createElement(p, quot;$tituloquot;); $NuevoNodo-appendChild($nodoTitulo); $nodoTitulo-setAttribute(class, titulo); $NuevoNodoHijo = $XML-createElement(subtitulo, $subtitulo); $nodoTitulo-appendChild($NuevoNodoHijo); $raiz-appendChild($NuevoNodo); } $NodoRefTitulo = $XML-getElementsByTagName('p')-item(0); $NodoRefTitulo-parentNode-insertBefore($nodoTitulo, $NodoRefTitulo); $XML-formatOutput = true; $XML-save(../xml/exposiciones.xml); The problem is that the special characters that I introduce through the form (á,é,ó...) corrupt the XML file, and when I try to update again the file, receipted this error: Warning: DOMDocument::load() [domdocument.load]: Input is not proper UTF-8, indicate encoding ! Bytes: 0xF3 0x6E 0x20 0x63 in I'd try to fix up it with the label ![CDATA[]], and by changing the encoding - UTF-8, iso-8859-1 as well, here: $XML = new DOMDocument('1.0', 'UTF-8'); -- $XML = new DOMDocument('1.0', 'iso-8859-1'); and in the XML file: ?xml version=1.0 encoding=utf-8? . and also I was try: $subtitulo = str_replace(ó , #243;, utf8_encode($subtitulo)); $subtitulo = str_replace(ó , oacute;;, utf8_encode($subtitulo)); When I open the XML file again i found an strange character between i and n exposicion (exposición): p class=tituloA-fotosubtitulo *exposiciﻩn*colectiva./subtitulo/p Anyone know how to solve this problem? Thanks for your help, Te0
Re: [PHP] Validate if the field of a form is empty
It works fine for me, foreach ( $_FILES['archivo']['name'] as $file ) { //echo $file; } if($file == ){ echo empty; }else{ //continue... } Thanks a lot Jim! Te0
[PHP] Validate if the field of a form is empty
Hi, I need to validate a field that work with Multifile plugin of Jquery, I want to check if the field is empty with php. [code] input name=archivo[] class=multi type=file accept=gif|jpg|png/ input name=button type=submit value=Submit [code] I've tried different ways but it does not work: for example: $field = $_FILES[archivo][name]; $field = $_FILES[archivo[]][name]; i dont know how to validate it, any help would be appreciated. Thanks,
Re: [PHP]
Thanks Ash, and so sorry I forgot to use the subject... ok, I'll read about insertBefore () method, Regards, te0
[PHP]
Hi, I have a photo gallery and I update it with a XML file like this: $NuevaCol = new SimpleXMLElement(../xml/ . $coleccionXML . '.xml', null, true); $first = $NuevaCol-addChild('coleccion'); $attsNuevaCol = $first-addAttribute('nombre_col', utf8_encode($titNuevaColEspacios)); $attsNuevaCol = $first-addAttribute('archivo', utf8_encode($uploadDir . $nombreMiniatura)); $NuevaCol-asXML(../xml/ . $coleccionXML . '.xml'); Now I try to include the new Child at the begining of the document because I want that the last update will be show the first in the gallery, do me explain? How can I do it?, Thanks in advance, te0