Insert into database recording in half

Asked

Viewed 145 times

3

I take the name of the news and insert in another table, but one of the fields is going by half, follows image of print:

Database imagem do bd

Source code of where send:

<input name="nomenoticia" type="hidden" id="nomenoticia"
       value="PC realiza apreensão de arma de fogo e droga no Bairro Jardim Esperança." size="80"
       maxlength="100">

Excerpt from the code I’m doing

     $noticia = $_POST['noticia'];
     $titulonoticia = $_POST['nomenoticia'];
     $nome = $_POST['nome'];
     $comentario = $_POST['comentario'];
     $status = $_POST['status'];


    $sqlInsert= "INSERT INTO comentarios   (noticia,nomenoticia,nome,comentario,status) VALUES (:noticia,:nomenoticia,:nome,:comentario,:status)";
    $stmt = DB::prepare($sqlInsert);
    $stmt->bindParam("noticia", $noticia);
    $stmt->bindParam("nomenoticia", $titulonoticia);
    $stmt->bindParam("nome", $nome);
    $stmt->bindParam("comentario", $comentario);
    $stmt->bindParam("status", $status);
    $stmt->execute();
  • 2

    It is not easy to identify a problem. First we do not know the maximum column size nomenoticia I think this is the one you’re saying is cut off. According to me I do not know if the software you are using is not showing the rest, if you have not slid the column limit to show more parts of the text, IE, that is just a visualization problem and not programming. With this information, it becomes easier to know what happens.

  • the column is empty(255) for the text is even cut even http://i.imgur.com/lB9WNNP.jpg

  • 1

    It is accentuation problem. You need to check the encoding that is fearing the data and what is the encoding used in the database. Incompatibility is discarding everything from the accent.

  • I really tested here in other fields and happened the same the Collation of the fields are in utf8_general_ci the bank is all in utf-8 and the pages are also with met utf-8

  • I solved the problem, it was really the goal utf-8 had not on the page of comments. Anyway thanks for the attention

  • I will answer then not to leave unanswered.

Show 1 more comment

1 answer

5


The cut is happening when you find an accent. So the problem is the incompatibility between the coding of the data being sent by the page and the coding waiting in the database column. Assuming that the database encoding really is utf8_general_ci and that it is hard to be wrong about this and that there is nothing in the middle of making conversions, it can only be concluded that the specific page that is sending the data is encoded differently than expected, even if unintentionally.

In fact the author acknowledged that the encoding from page to UTF-8.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.