Asked  7 Months ago    Answers:  5   Viewed   23 times

I want to save html-formatted text to database, but when I do that it is don't save html-symbols like < / > ' and others This is how I read article from database for editing:

<p class="Title">??????????? ???????:</p>
    <textarea name="EN" cols="90" rows="20" value="<?php echo htmlentities($articleArr['EN'], ENT_QUOTES, "UTF-8"); ?>" ></textarea>

after this generates such html-code:

<p class="Title">??????????? ???????:</p>
    <textarea name="EN" cols="90" rows="20" value="&lt;p class=&#039;Title&#039;&gt; ?????? &lt;/p&gt;" ></textarea>

So, I expect that this text will appear in my text field, in html-code of this page it is, but in text area is no.

In database I save it as:

<p class="Title"> Hello </p>

So how can I do the follow:

  1. Read from database html-formattedtext.
  2. Show it in textarea element.
  3. Edit and save it back to database.

Help me please, how can I save such texts properly, Thanx!

 Answers

44

Try using htmlspecialchars() on the string to put into the DB, and then, when pulling it back out, use htmlspecialchars_decode(). Might make a difference.

Wednesday, March 31, 2021
 
mario
answered 7 Months ago
29

In your phpMyAdmin directory, there will be a file called "config.inc.php".

Find the line where it sets the MaxRows value:

$cfg['MaxRows'] = 1000;

And change the value to whatever you want.

Wednesday, March 31, 2021
 
tika
answered 7 Months ago
50

my friend. There can be few reasons of this error.

  1. php.ini has wrong value for mysql.allow_local_infile. Must be - mysql.allow_local_infile = On

  2. If you are working locally you can try to remove the LOCAL from your SQL query. Maybe MySQL server settings just don't allow you to use the LOCAL keyword

  3. Only if you use cPanel: The problem is the phpMyAdmin that is built into the cPanel interface doesn't use the php built with apache. So you can rebuild apache all day long and it will not change how php is compiled [from cPanel forum]

Hope this will help you.

Wednesday, March 31, 2021
 
OMGKurtNilsen
answered 7 Months ago
48

simply place the content of url in an hidden field.

<input type="hidden" name="canvascontent" id="canvascontent" />

in javascript (with jquery):

var url = canvas.toDataURL('image/png');
$("#canvascontent").val(url);
Thursday, August 12, 2021
 
muaaz
answered 3 Months ago
69

This worked for me, I have changed two line code, Thank you all for your contribution

private void sendEmail(String email,String name) throws Exception{
    Thread thread=new Thread(){
        @Override
        public void run() {

            try{
                String msg="Dear<b> "+name.toUpperCase()+" </b>,<p> On Behalf of someone we would like to wish you a Many many Happy returns of the day</p> <p style=color:red;>Happy Birthday and Have a Great Day.</p>n n Thank You!";

                MimeMessage message = mailSender.createMimeMessage();
                MimeMessageHelper helper = new MimeMessageHelper(message,true);
                helper.setTo(email);
                helper.setText(msg);
                message.setContent(msg, "text/html");                   
                helper.setSubject("BirthDay");
                mailSender.send(message);

            }catch (Exception e){}
        }
    };
    thread.start();

}

enter image description here

Saturday, August 21, 2021
 
Naveed S
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :