ang3lx
13-06-2010, 23:19
Salve ragazzi,
hp un problema un pò strano
faccio una query tramite ajax che richiama via POST questo script che si occupa di inserire il record nel db e di stamparlo a video
il problema è che quando stampa sotto
<?php echo $textcontent; ?>
stampa tutto per bene, cioè con le è accentate
però se vado a controllare nel db mi ritrovo robbe tipo è
ora... htmlspecialchars() non doveva trasformarmi le entità html...e quindi salvare un qualcosa tipo è nel db e non è?
non capisco da cosa possa dipendere
<?php
require_once("db.php");
if(isSet($_POST['textcontent'])){
//$textcontent=$_POST['textcontent'];
// Sql data insert values into comment table
$data = time();
$textcontent = htmlspecialchars(trim("$_POST[textcontent]"));
mysql_query("INSERT INTO comments (post_id,msg,userid,data) VALUES ('$_POST[com_msgid]','$textcontent','$_SESSION[username]','$data')");
$qry = mysql_query("SELECT id,data,userid FROM comments WHERE post_id = '$_POST[com_msgid]' AND userid = '$_SESSION[username]' AND data = '$data' ORDER BY id DESC LIMIT 1");
$rowtmp = mysql_fetch_array($qry);
$qry_2 = mysql_query("SELECT foto_profilo FROM users WHERE username = '$_SESSION[username]'");
$my_prof = mysql_fetch_array($qry_2);
}
?>
<div class="load_comment">
<code class="bar<? echo $rowtmp["id"]; ?>" >
<?
if($_SESSION["username"] == $rowtmp["userid"]){
?>
<span class="delete_button" style="float:right; width:40px; text-align: center;"><a href="#" id="<?php echo $rowtmp["id"]; ?>" class="delete_update"><img src="images/hr.gif"></a></span>
<?
}
?>
<?
if($my_prof["foto_profilo"]){
print("<img src=\"TT.php?src=$my_prof[foto_profilo]&w=40\" style=\"float:left; margin-right:5px; padding:5px;\"/>");
}else{
print("<img src=\"TT.php?src=foto/no_foto.png&w=40\" style=\"float:left; margin-right:5px; padding:5px;\"/>");
}
?>
<b><a href="profile.php?u=<? echo $rowtmp["userid"]; ?>"><? echo $_SESSION["username"]; ?></a></b> commenta: <small>(<? echo _ago($rowtmp["data"]);?>fa)</small><br />
<?php echo $textcontent; ?>
<br />
</code>
</div>
ringrazio tutti in anticipo
hp un problema un pò strano
faccio una query tramite ajax che richiama via POST questo script che si occupa di inserire il record nel db e di stamparlo a video
il problema è che quando stampa sotto
<?php echo $textcontent; ?>
stampa tutto per bene, cioè con le è accentate
però se vado a controllare nel db mi ritrovo robbe tipo è
ora... htmlspecialchars() non doveva trasformarmi le entità html...e quindi salvare un qualcosa tipo è nel db e non è?
non capisco da cosa possa dipendere
<?php
require_once("db.php");
if(isSet($_POST['textcontent'])){
//$textcontent=$_POST['textcontent'];
// Sql data insert values into comment table
$data = time();
$textcontent = htmlspecialchars(trim("$_POST[textcontent]"));
mysql_query("INSERT INTO comments (post_id,msg,userid,data) VALUES ('$_POST[com_msgid]','$textcontent','$_SESSION[username]','$data')");
$qry = mysql_query("SELECT id,data,userid FROM comments WHERE post_id = '$_POST[com_msgid]' AND userid = '$_SESSION[username]' AND data = '$data' ORDER BY id DESC LIMIT 1");
$rowtmp = mysql_fetch_array($qry);
$qry_2 = mysql_query("SELECT foto_profilo FROM users WHERE username = '$_SESSION[username]'");
$my_prof = mysql_fetch_array($qry_2);
}
?>
<div class="load_comment">
<code class="bar<? echo $rowtmp["id"]; ?>" >
<?
if($_SESSION["username"] == $rowtmp["userid"]){
?>
<span class="delete_button" style="float:right; width:40px; text-align: center;"><a href="#" id="<?php echo $rowtmp["id"]; ?>" class="delete_update"><img src="images/hr.gif"></a></span>
<?
}
?>
<?
if($my_prof["foto_profilo"]){
print("<img src=\"TT.php?src=$my_prof[foto_profilo]&w=40\" style=\"float:left; margin-right:5px; padding:5px;\"/>");
}else{
print("<img src=\"TT.php?src=foto/no_foto.png&w=40\" style=\"float:left; margin-right:5px; padding:5px;\"/>");
}
?>
<b><a href="profile.php?u=<? echo $rowtmp["userid"]; ?>"><? echo $_SESSION["username"]; ?></a></b> commenta: <small>(<? echo _ago($rowtmp["data"]);?>fa)</small><br />
<?php echo $textcontent; ?>
<br />
</code>
</div>
ringrazio tutti in anticipo