0

I have this html string

<p><span style="color: #4f4f4f; font-family: Arial; font-size: 12px; font-style: normal; 
font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 
15.600000381469727px; orphans: 2; text-align: -webkit-left; text-indent: 0px; text-transform:
 none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -
webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: 
none;">Numerical estimation is key in many craft and technical jobs where the ability to 
quickly and accurately estimate material quantities is essential. The speed at which you can 
answer these questions is the critical measure, as most people could achieve a very high sco
re given unlimited time in which to answer. You can therefore expect 25-35 questions in 10 
minutes or so.</span></p>

I want to store this in my database, but app is getting crashed while executing query. Any idea if I should remove any particular symbol or anything or is it because of it's length?

3
  • Have you tried to save plain text? Any error messages? Commented Apr 3, 2013 at 11:49
  • stackoverflow.com/questions/4577904/… Commented Apr 3, 2013 at 11:49
  • 1
    Is there meant to be a " after style? Surely that would break it.. Commented Apr 3, 2013 at 11:49

2 Answers 2

3

You should perform SQL Escape operations in general.

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

Comments

1

As long as you're inserting it as a string it should work.. Try this:

    $htmlString = '<p><span style="color: #4f4f4f; font-family: Arial; font-size: 12px; font-style: normal; 
    font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 
    15.600000381469727px; orphans: 2; text-align: -webkit-left; text-indent: 0px; text-transform:
     none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -
    webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: 
    none;">Numerical estimation is key in many craft and technical jobs where the ability to 
    quickly and accurately estimate material quantities is essential. The speed at which you can 
    answer these questions is the critical measure, as most people could achieve a very high sco
    re given unlimited time in which to answer. You can therefore expect 25-35 questions in 10 
    minutes or so.</span></p>';

I basically replaced the "" with '' because your string already contained double quotes and that would break.

As Ismet Alkan stated it is always good practice to perform SQL Escapes when inserting data.

Also make sure your database column is compatible with the string, so setting the type as TEXT should do the trick.

Comments

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.