PHP、MYSQL、HTML で簡単なブログを作成しています。アポストロフィと引用符を表示する際に問題が発生し、(html ページで) 「例」を表示する代わりに「例」が表示されます。エスケープ文字列などを使用していますが、まだ機能していません:( ページ:
<?php
$servidor = "XX";
$bd = "XX";
$usuario = "XX";
$senha = "XX";
mysql_connect($servidor, $usuario, $senha) or trigger_error(mysql_error());
mysql_select_db('a3722962_main') or trigger_error(mysql_error());
$tutoID = $_GET['tuto'];
$query = mysql_query("SELECT * FROM tutorials WHERE id = '$tutoID'");
while($line = mysql_fetch_array($query)) {
$content = $line['text'];
$title = $line['title'];
$creator = $line['creator'];
$name = $line['name'];
$idtest = $line['id'];
}
{echo "$content";}
?>
投稿ページ:
<?php
mysql_connect($servidor, $usuario, $senha) or trigger_error(mysql_error());
mysql_select_db('a3722962_main') or trigger_error(mysql_error());
$usuario = mysql_real_escape_string($_SESSION['UsuarioNome']);
$title = mysql_real_escape_string($_POST['title']);
$post = mysql_real_escape_string($_POST['post']);
$realname = $_SESSION['usuario'];
$lang = $_POST['lang'];
$cat = $_POST['cat'];
$dopost = "INSERT INTO tutorials VALUES ('', '$title', '$post', '$usuario', '$realname', NOW( ), '$cat', '$lang')";
if($title == "" or $post == "") {
echo "<script>alert(Please, fill out the damn form...);
location.href='inside' </script>";
} else {
echo "<script>alert(Your post probably has been added!);
location.href='inside'</script>";
}
if (!empty($_POST) AND (empty($post) OR empty($title))) {
echo "<script>alert('Please fill out the damn posting form.');
location.href='inside'</script>";
} else {
$query = mysql_query($dopost);
};
if($query) {
echo "<script>alert('The post that you have just setup has been added successfully! :D');
location.href='inside'</script>";
} else {
echo "Could not add this post to the database.";
echo mysql_error();
}
?>
皆さんありがとう!