EasyNoteの Web サイトでは、改行に問題があります。
body onload では、次のように 3 秒ごとにメモを自動アップロードするタイマーを設定します。
<body onload="setInterval(uploadNote,3000);current = 1;">
そして、uploadNote のコードは次のとおりです。
function uploadNote() {
var note = current+document.getElementById(\'note\').value; //current is the number of the note selected\' because echoed
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){}
}
xmlhttp.open("GET","uploadnote.php?q="+note,true);
xmlhttp.send();
}
そして、このphpコードがあります:
$note = $_GET["q"]; //contains both notenumber as first digit and note
echo($note."\n"); //for debugging reasons
$notenumber = substr($note, 0, 1);
$notecontent = substr($note, 1, strlen($note));
$notecontent = str_replace("'","''",$notecontent);
$notecontent = nl2br($notecontent);
echo($notecontent); //for debugging reasons
$request = 'UPDATE notes SET note'.$notenumber.' = "'.$notecontent.'" WHERE mail LIKE "'.$email.'"';
$result = mysql_query($request);
問題は、テキストエリアの改行文字が完全に消去されるため、php-snippet の結果は改行なしのテキストの 2 倍になり、データベースにも表示されることです。ただし、データベースに直接挿入すると、テキストエリアに改行が表示されても問題はありません。
助けていただければ幸いです。
編集: 更新された uploadNote() 関数:
function uploadNote() {
var note = current+document.getElementById(\'note\').value;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){}
}
xmlhttp.open("POST","uploadnote.php",true);
xmlhttp.send("note="+note);
}
およびphp:
$note = $_POST["note"];
echo($note."\n");
$notenumber = substr($note, 0, 1);
$notecontent = substr($note, 1, strlen($note));
$notecontent = mysql_real_escape_string($notecontent);
echo($notecontent);
$request = 'UPDATE notes SET note'.$notenumber.' = "'.$notecontent.'" WHERE mail LIKE "'.$email.'"';
$result = mysql_query($request);
今の問題は、何も機能しないことです。メモは MySQL データベースで更新されません。