Ecco il mio problema:
Codice PHP:
<html>
<head>
<script>
function assegnaXMLHttpRequest_()
{
// lista delle variabili locali
var
// variabile di ritorno, nulla di default
XHR = null,
// informazioni sul nome del browser
browserUtente = navigator.userAgent.toUpperCase();
// browser standard con supporto nativo
// non importa il tipo di browser
if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
XHR = new XMLHttpRequest();
// browser Internet Explorer
// è necessario filtrare la versione 4
else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) {
// la versione 6 di IE ha un nome differente
// per il tipo di oggetto ActiveX
if(browserUtente.indexOf("MSIE 5") < 0)
XHR = new ActiveXObject("Msxml2.XMLHTTP");
// le versioni 5 e 5.5 invece sfruttano lo stesso nome
else
XHR = new ActiveXObject("Microsoft.XMLHTTP");
}
return XHR;
}
function invia(){
reqq = assegnaXMLHttpRequest_();//funzione che assegna l'oggetto presa da html.it
reqq.open('POST', "lettura.php", true);
reqq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
reqq.send("variabile=èèèèè");
reqq.onreadystatechange = function(){
if (reqq.readyState == 4){
if (reqq.status == 200){
document.getElementById("elemento").innerHTML=reqq.responseText;
}else{
alert(reqq.status+" "+reqq.responseText);
}
}
};
}
</script>
</head>
<body>
<?
echo "<a href=\"#\" onclick=\"invia();\">Invia</a>";
echo "<div id=\"elemento\">";
echo "</div>";
?>
</body>
</html>
lettura.php
Codice PHP:
$db=$cls->connessione();
$db->query("insert into tabella
(campo)
values
('$_POST[variabile]')");
$db->query("insert into tabella
(campo)
values
('èèè')");
Nel primo caso memorizzerà: èèèèè - nel secondo èèè.
Secondo te il problema dov'è?