2

I'm creating a form that has a text area that uses TinyMCE.

When the form is submitted, the form sends the information using POST to a PHP script.

In that PHP, I'm trying to store the information from the TinyMCE in a database using MeekroDB.

The thing is that MeekroDB is storing my HTML from TinyMCE this way:

enter image description here

Is there any way of storing normal HTML?

This is my code:

DB::query("INSERT INTO products (title, price, article_nr, description, adicional_info, active, sold)
          VALUES (%s, %s, %s, %s, %s, %s, %s)",
            $query_data['title'],
            $query_data['price'],
            $query_data['article_nr'],
            $query_data['description'],
            $query_data['adicional_info'],
            $query_data['active'],
            $query_data['sold']
            )

Already tried this way:

DB::query("INSERT INTO products (title, price, article_nr, description, adicional_info, active, sold)
          VALUES (%s, %s, %s, %l, %l, %s, %s)",
            $query_data['title'],
            $query_data['price'],
            $query_data['article_nr'],
            $query_data['description'],
            $query_data['adicional_info'],
            $query_data['active'],
            $query_data['sold']
            )

but it returns an error.

Michael Fromin
  • 13,131
  • 2
  • 20
  • 31
Alexandre Cristo
  • 341
  • 3
  • 16
  • You'll need to check some data here: What does the data look like when entered into TinyMCE? Right after retrieving it, before sending it to the server? On the server end before entering it into the database? When you retrieve it from the database? When you place it on the page? The data representation is faltering somewhere, but it can falter at any one of these point and will have different implications depending on which point it is. Please determine where you first see the HTML in its escaped form so we can narrow the problem down further. – B. Fleming May 14 '18 at 18:43
  • The HTML is well encoded when getting with $_POST. It only changes when submitting to the database using the MeekroDB. – Alexandre Cristo May 14 '18 at 19:30
  • Unfortunately I'm unable to find any information regarding the auto-conversion from HTML to entity encoding. That being said, PHP has the handy `html_entity_decode()` function that you might find helpful. – B. Fleming May 14 '18 at 19:38

1 Answers1

0

Hello @Alexandre Cristo,

Meekrodb is one of the good mysql library for php. I have started my work with meekrodb just before a month.

So your answer is :

You can do by following query in #meekrodb.

// MeekroDB lets you INSERT with a very simple format. You can tell at a glance if everything is right.

$data = array(
  'name' => $name,
  'address' => $address,
  'full_description' => $full_description
)
DB::insert('mytable', $data);

So this is the solution for html source insert into db using meekrodb library. I have done it many times for html source insert into database.

Udo E.
  • 2,665
  • 2
  • 21
  • 33