1

In my data have so much special characters values and I want to insert all the database but following are the issues which I face..

When I add the entries into database its goes OK and its displayed OK but when I generate XML it's through too much error I check almost many functions of PHP but nothing work even no one works .. so I think to insert the records in the database which have those special characters error not comes.

And when I simply write the XML its write but not ignore those special characters its has come in XML also .. please recommend me is it possible to insert the data and either some techniques to display and write to the XML properly

I use PHP, MYSQL, XML

2
  • Please show some code and describe the exact problem you have. This is very difficult to make sense from. Commented Mar 21, 2011 at 13:48
  • don't post the same question twice !! stackoverflow.com/questions/5376775/… Commented Mar 21, 2011 at 14:08

3 Answers 3

1

If you are to add values to the DB that have special characters in it, use mysql_real_escape_string(). I think it'll be will be very useful in your case.

Sign up to request clarification or add additional context in comments.

3 Comments

why u recommend is it really helps .. !! ?? !! and when should i use when write xml or when insert the records into database
when you write the values to the DB use mysql_real_escape_string(), it'll take care of all the special characters, so you wont get any problems in retrieving it. when writing it in an XML make sure you use <![CDATA[your field value]]>
should i use htmlspecialchars when generating XML here is the sample $_xml .=" <pName><![CDATA[" . htmlspecialchars($row['pName'],ENT_QUOTES) . "]]></pName>";
0

Probably, you have to use utf-8, or convert your encoding correctly, and it's preferable to use CDATA tag in XML. What encoding do you use for your characters? The actual solution would depend on the details which you didn't provide.

3 Comments

i tried but its not working properly CDDATA and when i write XML i write following htmlspecialchars($databaseRow,ENT_QUOTES);
please specify what are those special characters that break up your XML. And what are the XML parser errors? Also try htmlentities().
in this line: And we’re running outta time, after we "'" this error shoot .. please tell me .. there are many special characteres ..
0

You need to ensure that from end to end you're using the same encoding. Best option to me is UTF-8.

You must consider : - the charset of your database (easy to see and update with phpmyadmin for instance) - the content-type of you website :

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  • and the xml encoding too

    <{qmark}xml version="1.0" encoding="UTF-8" ?>

From your description, you should try to see which encoding is used by your website and your xml file. I think you have the wrong xml encoding (or no encoding set).

1 Comment

no i use correct XML only uni code make me crazy :( i use $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; and website its define... meta tag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.