我正在用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();
}
?>
全部谢谢!