2013-03-22 2 views
-1

У меня есть форма, которую я разработал, и я намерен принять любой контент UTF-8 и вставить его в базу данных MySQL. Я использовал PDO с charset utf-8 в качестве кодировки для подключения к базе данных. Запрос на вставку по-прежнему не работает, когда контент имеет такие символы, как одиночные кавычки. Какую встроенную функцию я должен использовать на своем входном контенте, прежде чем использовать его в запросе. Ниже приведен пример запроса, который формируется непосредственно перед вставкой в ​​базу данныхPHP: обработка котировок до выполнения PDO

INSERT INTO dbname.table 
       (input_xml) 
      VALUES 
       ('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
      <ip_Input> 
       <ip_xml> 
        Qaiku.com – What Can We 
        Learn From Failure?By Guest Blogger, September 11, 2012, Leave a 
        CommentEditor's note: I think we in the tech press have the tendency to 
        focus on the positive stories and forget about the startups that didn't live up 
        their expectations. Our Sofanatics coverage this past week has been one of the 
        few times we've covered abandoned projects, which is a pitty because there are a 
        lot to learn from "failures." Below we have a long read from Eero Holmila which 
        is one part eulogy, and another part what he's learned from the now-announced 
        shutdown of Qaiku.com.Qaiku.com might be a familiar name for some of the 
        readers of Arctic Startup. However, I am quite sure that the background and the 
        rough road from high hopes to a bitter decline probably is not. I am the CEO of 
        Rohea, a company behind a handful of quite successful Finnish websites like 
        Kotikokki.net, Kuvake.net, Mikseri.net and of course a less successful 
        Qaiku.com.I am going to share some lessons learned through the trip. I hope 
        some of it might be of use, spark up ideas or if nothing else, be at least a bit 
        entertaining. One last important disclaimer: all the opinions are my own.Now 
        without further delay, this is the story of 
        Qaiku. 
       </ip_xml> 
      </ip_Input> 
       '); 

ответ

0

Функция вы должны использовать это PDOStatement::bindValue(). Прежде чем это сделать, вам также следует прочитать о SQL Injection и правильном способе использования PDO с параметризованными запросами.

Смежные вопросы