Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: bladeymolly en 11 Marzo 2015, 19:03 pm



Título: ayuda con problema en base de datos
Publicado por: bladeymolly en 11 Marzo 2015, 19:03 pm
hola mi problema esque instale el phpnews, lo modifique para trabajar en utf-8 y en wampserver funciona perfecto pero al pasarlo al servidor de nixiweb no me reconoce las ñ y los acentos, lo que hace es que corta la palabra y no la guarda en la base de datos, pero si ponga la letra ñ en la base de datos si que me aparece en la web, el problema recide en que no guarda los datos en utf-8 en la base de datos. aqui dejare el admin.php..

segun e leido puede ser problema de los htmlentityes porque el programa es viejo y estaba para iso. aver si algien puede ayudarme a areglarlo.. desde ya muchas gracias.

las lineas del htmlentityes:

Código:
 // Don't let the evil double quotes win! >:D
  $_POST['subject'] = htmlentities($_POST['subject'], ENT_COMPAT);

 /* Check if replace linebreaks checkbox is ticked */
  if ($_POST['break'] == 1)
  {
    $replace = 'checked="checked"';
    $_POST['titletext'] = str_replace('<br />', "\r\n", $_POST['titletext']);
    $_POST['maintext'] = str_replace('<br />', "\r\n", $_POST['maintext']);
  }

  /* Remove special characters */
  $chars = array('&lt;','&gt;');
  $charsto = array('<','>');

  $_POST['titletext'] = str_replace ($chars, $charsto, $_POST['titletext']);
  $_POST['maintext'] = str_replace ($chars, $charsto, $_POST['maintext']);

  $_POST['titletext'] = un_htmlentities($_POST['titletext']);
  $_POST['titletext'] = stripslashes($_POST['titletext']);
  $_POST['maintext'] = un_htmlentities($_POST['maintext']);
  $_POST['maintext'] = stripslashes($_POST['maintext'])

/* Converts entities in the given string back to their character */
function un_htmlentities($string)
{
  /* Get the translation table */
  $ttable = get_html_translation_table(HTML_SPECIALCHARS);

  /* Change the translation table to char <> entity */
  $ttable = array_flip($ttable);

  /* Convert all entities to ther character */
  $decstring = strtr($string, $ttable);

  return $decstring;
}

  /* Find out the page creation time */
  $time_end = getMicrotime();


Título: Re: ayuda con problema en base de datos
Publicado por: yovaninu en 12 Marzo 2015, 19:37 pm
Hola, has probado en poner correctamente los encabezados?

<!DOCTYPE HTML>
Código
  1. header ('Content-type: text/html; charset=utf-8');
  2.  
  3. /*antes de esto, ya debe haber una conexión a mysql*/
  4.        $id=conectar(); //<-- ejemplo
  5.  
  6. mysql_query("SET NAMES 'utf8'");
  7.  
  8.  
  9.