Error returning mysql database data

1

I made a normal form that returns the data in HTML. So I decided to insert images into the database and then gave a warning:

  

"Notice: Array to string conversion in   E: \ sites \ htdocs \ progdesenv2 \ admin \ acao.php on line 14 "

As far as I understand, you're saying it's a conversion array for right text? So, I had some doubts:
1 - How do I use text and image together?
2 - When I enter the data in the form it only brings in the HTML of the last record I inserted but I wanted it to bring all the data from the database (type a table). 3 - In my last post they told me to use msqli instead of msql but I tried to use it and gave a lot of errors so I took it, have some way to use it or just put the "i" in front of msql? 4 - I searched the internet and put in the field of the image that it is type LONGBLOB is the best alternative?

BACK THE BANK'S DATA

<?php
include "conexao.php";
$busca = mysql_query("SELECT * FROM formulario  ORDER BY nome ASC");
if (mysql_num_rows($busca))
{

    while ($resultado = mysql_fetch_array($busca))
    {
        extract($resultado);
        $l1 = $nome;
        $l2 = $idade;
        $l3 = $editor1;
        $l4 = $imagem;
    }       
}

?>

INSERT THE DATA ON THE BANK

<?php
include "conexao.php";
if(isset($_POST['acao']) && $_POST['acao'] == 'enviado'){

        $nome = $_POST['nome'];
        $idade = $_POST['idade'];
        $telefone = $_POST['telefone'];
        $editor1 = $_POST['editor1'];
        $imagem = $_FILES['imagem'];

        if(empty($nome) || empty($idade) || empty($telefone) || empty($editor1) || empty($imagem)){
                echo "Preencha os campos corretamente";
            }else{
                $insereDados = mysql_query("INSERT INTO formulario (nome, idade, telefone, editor1, imagem) VALUES ('$nome', '$idade', '$telefone', '$editor1', '$imagem' )");  
                echo "Enviado com sucesso!!";
            }
    }
?>

HTML

<section class="formulario">
  <form action="acao.php"  method="post" enctype="multipart/form-data">
    <input type="text" name="nome" placeholder="Nome:"><br>
    <input type="text" name="idade" placeholder="Idade:"><br>
    <input type="text" name="telefone" placeholder="Telefone:"><br>
    <input name="imagem" type="file"/><BR>
    <div class="tarea"><textarea class="ckeditor" name="editor1" cols="30" rows="10" placeholder="Mensagem:" ></textarea></div>
    <input type="hidden" name="acao" value="enviado">
    <input type="submit" value="Enviar Informações">
  </form>
</section>
  

I have updated the code below and now it does not give any error only that in the place of the image it brings written array what can be ?:

<div>
<hgroup><h2>NOME</h2><h2>IDADE</h2><h2>MENSAGEM</h2><h2>IMAGEM</h2></hgroup>
    <?php
    include "conexao.php";
    $busca = mysql_query("SELECT * FROM formulario  ORDER BY nome ASC");
    while ($resultado = mysql_fetch_array($busca)){

     echo '<div>'.$resultado['nome'].'</div>';
     echo '<div>'.$resultado['idade'].'</div>';
     echo '<div>'.$resultado['editor1'].'</div>';
     echo '<div>'?><img src ="imagem/<?php echo $resultado['imagem']?> <?php echo '</div>';
} ?>
</div>  
    
asked by anonymous 23.04.2015 / 23:46

1 answer

1

After inserting the record, make the query and display all the results with the formatting inside the while and not outside.

You have written the values after the while this means that only the last result will be displayed, using extract does not seem necessary. Do this to get the desired result

<?php while ($resultado = mysql_fetch_array($busca)){ ?>
<div>
    <hgroup><h2>NOME</h2><h2>IDADE</h2><h2>MENSAGEM</h2><h2>IMAGEM</h2></hgroup>
    <div><?php echo $resultado['nome'];?></div>    
    <div><?php echo $resultado['idade'];?></div>
    <div><?php echo $resultado['editor1'];?></div>
    <div><?php echo $resultado['imagem'];?></div>
</div> <br>
<?php } ?>
    
24.04.2015 / 01:21