Ver Mensaje Individual
  #17 (permalink)  
Antiguo 26/04/2011, 20:57
JAI_ME
 
Fecha de Ingreso: enero-2010
Mensajes: 247
Antigüedad: 14 años, 3 meses
Puntos: 2
Respuesta: ERROR guardar texto formateado en mysql

Cita:
Iniciado por Triby Ver Mensaje
Te podemos proporcionar infinidad de ejemplos, pero seria mejor que muestres el codigo, del formulario y tambien donde obtienes los datos, como armas la consulta y como la ejecutas. Va a ser mas rapido solucionar tu problema.
gracias triby por su atencion.


<form id="fcreanoticia" name="fcreanoticia" action="noticias.php<? echo "?&dto=".$_GET['dto']."&cid=".$_GET['cid']."&cam=".$_GET['cam']."&ino=".$_SESSION["idnoticia"]?>" method="post">

<!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->

<textarea id='mnota' name='mnota' rows='15' cols='90' style='width: 90%'>
<?
$idnot = $_SESSION["idnoticia"];
if($idnot!=''){
$sql = "select * from noticia
where noidnoticia = '$idnot'";
$resEmp = mysql_query($sql, $conexion);
$rowEmp = mysql_fetch_assoc($resEmp);
echo $rowEmp["NOMENSAJE"];
}

?>
</textarea>

<div style="float:left;">
<?


$idcam = base64_decode($_GET['cam']);
$sql = "select * from noticia
where noidcampo = $idcam";
$resEmp = mysql_query($sql, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
$resul = "<span style='color:#000000; float:left; margin:3px 10px 0 0;'>Noticias</span>";
$i = 0;

if($totEmp > 0)
while($rowEmp = mysql_fetch_assoc($resEmp)){
$i++;
// $resul .= "<div id='noticia'>
// <a href='javascript:void(0);' onclick='xajax_vernoticia(".$rowEmp['NOIDNOTICIA'].");'>".$i."</a></div>";
// $resul .= "<button id='noticia' onclick='javascript:submit;". creasession($rowEmp['NOIDNOTICIA']) ." ' >".$i."</button>";
$resul .= "<input style='display:none;' type='radio' name='rnoticia[]' id='rnoticia".$rowEmp['NOIDNOTICIA']."' value='".$rowEmp['NOIDNOTICIA']."' onclick='xajax_vernoticia(xajax.getFormValues(fcre anoticia));' /><label id='noticia' for='rnoticia".$rowEmp['NOIDNOTICIA']."'>".$i."</label>";

}
// onclick='xajax_vernoticia(".$rowEmp['NOIDNOTICIA'].");'>".$i."</a></div>";

echo $resul;
?></div>


<div style="clear:both; float:left; margin-top:10px;">

<input type="button" name="bsave" id="bsave" value="Publicar" onclick="xajax_guardar(xajax.getFormValues('fcrean oticia'));"/>
<input type="reset" name="blimpiar" value="Limpiar" />
<input type="button" name="bprueba" id="bprueba" value="cambiar" onclick="xajax_vernoticia(4);"/>
</div>

</form>




Funcion guardar en xajax

function guardar($datos){

$respuesta = new xajaxResponse();
$respuesta->setCharacterEncoding('ISO-8859-1');
include("conexion.php");
// $mensaje = mysql_real_escape_string($datos["mnota"]);

//strip_tags(nl2br(Texto ingresado)

$mensaje = strip_tags(nl2br($datos["mnota"]));
// $mensaje = var_dump($datos["mnota"]);

$idcam = base64_decode($_GET['cam']);
$fecha = date("Y-m-d");
$publica = 0;

$sql = "insert into noticia (NOIDCAMPEONATO,NOMENSAJE,NOFECHA,NOSWPUBLICAR) values($idcam,'$mensaje','$fecha',$publica)";
mysql_query($sql, $conexion);


$respuesta->Script("alert('Noticia Guardada');");

return $respuesta;
}


Estos script funcionan bien cuando el texto no tiene formato, pero le creo un formato al texto no guarda nada.


espero me puedan ayudar.