Я пишу простое, похожее на cms решение, чтобы отслеживать мои глупые идеи.Все идет отлично, но сейчас у меня возникают трудности с внедрением плагина Xinha RTE в мое приложение.
Я следовал их учебному пособию на месте, и, похоже, оно работает, но ...
При форматировании текста, заголовков, абзацев и т. Д. Хотя теги правильно сохраняются в базе данных mysql:
<h1>heading</h1>
<p>text example</p>
, они отображаются как:
<h1>heading</h1><p>text example</p> (concatenated and NOT formatted , displaying tags in stead)
или
<p>tesy</p> <h4>fgfg<br /></h4> <h2> </h2>
последний пример вывода, потому что я сделал это изменение:
//$postCon = mysql_real_escape_string($postCon);
$postCon = htmlspecialchars($postCon);
Это было только потому, что кто-то на их форуме сказал, что было бы "глупо" избегать специальных символов html - так какhtml тэги состоят из них.
Мне действительно трудно определить реальную проблему.следовательно, мой вопрос немного неаккуратен.Я надеюсь, что некоторые из них были там, где я сейчас, и могут дать какое-то объяснение или руководство в правильном направлении.
Сейчас я пойду выпью кофе и подумаю над этим, и принесу обновления, если я что-нибудь получу.новый.Пока я просто оставлю вам скрипт, который выполняет обработку сообщений.
спасибо,
<?php
include_once 'bin/configDb.php';
include_once 'bin/connectDb.php';
include_once 'header.php';
//get stuff from post
$topicSub = $_POST['topic_subject'];
//$topicSub = mysql_real_escape_string($topicSub);
$topicSub = htmlspecialchars($topicSub);
$topicCat = $_POST['topicCat'];
// $topicCat = mysql_real_escape_string($topicCat);
$sesId = $_GET['username'];
//the form has been posted, so save it
//insert the topic into the topics table first, then we'll save the post into the posts table
$postCon = $_POST['post_content'];
//$postCon = mysql_real_escape_string($postCon);
$postCon = htmlspecialchars($postCon);
$sql = "INSERT INTO
topics(topic_subject, topic_date, topic_cat, topic_by)
VALUES('$topicSub', NOW(), '$topicCat', '$sesId' )";
$result = mysql_query($sql);
if(!$result)
{
//something went wrong, display the error
echo 'An error occured while inserting your data. Please try again later.' . mysql_error();
$sql = "ROLLBACK;";
$result = mysql_query($sql);
}
else
{
//the first query worked, now start the second, posts query
//retrieve the id of the freshly created topic for usage in the posts query
$topicId = mysql_insert_id();
$sql = "INSERT INTO
posts(post_content,
post_date,
post_topic,
post_by)
VALUES
('$postCon', NOW(), '$topicId', '$sesId' )";
$result = mysql_query($sql);
if(!$result)
{
//something went wrong, display the error
echo 'An error occured while inserting your post. Please try again later.' . mysql_error();
$sql = "ROLLBACK;";
$result = mysql_query($sql);
}
else
{
$sql = "COMMIT;";
$result = mysql_query($sql);
//after a lot of work, the query succeeded!
echo 'You have successfully created <a href="topic.php?id='. $topicid . '">your new topic</a>.';
header("location:admin.php");
}
}
include_once 'footer.php';
?>