Вот мой кодВставить запрос с особым характером в PHP
<?php
$con = mysql_connect('localhost','test','test');
mysql_select_db('test',$con);
require_once("xml2json.php");
$testXmlFile = 'mytest.xml';
$xmlStringContents = file_get_contents($testXmlFile);
$jsonContents = "";
$jsonContents = xml2json::transformXmlStringToJson($xmlStringContents);
$obj =json_decode($jsonContents);
$rows = array();
foreach($obj->rss->channel->item as $item) {
echo $item->title."\n";
echo $item->description."\n";
$rows[] = "('".mysql_real_escape_string($item->title)."','".mysql_real_escape_string($item->description)."')";
}
$del_horoscope = "delete from jos_horoscope";
mysql_query($del_horoscope);
$query = mysql_real_escape_string("INSERT INTO `jos_horoscope` (`title`,`description`) VALUES ".implode(', ',$rows));
mysql_query($query);
if (!mysql_query($query)) echo 'Oh no! Something went wrong with the query: '.mysql_error();
?>
Я не могу вставить название и описание в БД. Он всегда говорит
Oh no! Something went wrong with the query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'What\'s special today for you\',\'Your birth on the 25th day of the month (7 e' at line 1
Некоторые из данных, которые я пытаюсь вставить это
What's special today for you
Your birth on the 25th day of the month (7 energy) modifies
your life path by giving you some special interest in technical,
scientific, or other complex and often hard to understand subjects.
You may become something of a perfectionist and a stickler for
details. Your thinking is logical and intuitive, rational and responsible.
Your feelings may run deep, but you are not very likely to let them
show. This birthday makes you a more private person, more
introspective and perhaps more inflexible.
Aries Horoscope for Thursday, April 25, 2013
Although most of us when we make a decision we don`t have to worry what it will impact for the world we live in, but when you make a decision we have to remember that it does impact our society in so many ways. Our choice has to be an ethical one, regardless of the outcome. Your emotions are brought into more conscious focus these few days. You may find that you can more easily communicate your feelings at this time.
Первая линия название и остальное Описание до Овна гороскоп. После этого начинается другое название. Пожалуйста, помогите мне . Я пробовал много вариантов, но он не работает для меня
Вот моя структура таблицы
Пожалуйста, помогите мне.
это 2013 год, и люди до сих пор не нашли времени, чтобы прочитать о XSS и SQL-инъекции ... – pocesar
@pocesar Пожалуйста, помогите мне ... какие улучшения я использую в своем коде .. – Yogus
@ user2320808 mysql_ * функции лишены , [вы можете использовать mysqli_ * вместо этого] (http://idiallo.com/blog/2013/04/dealing-with-mysql-once-and-for-all.html). Не то, чтобы он решает вашу проблему, но это будет хороший старт, чтобы правильно исправить ваш запрос в php. – Ibu