1
I made a normal form that returns the data in HTML. So I decided to insert images in 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 it, are you saying it’s a text-to-text conversion array right? So I was left with some questions:
1 - How do I use text and image together??
2 - When I insert the data into the form it only brings in the HTML of the last record I entered but I wanted it to bring all the database data (like a table).
3 - In my last post I was told to use msqli instead of msql but I tried to use and there were many errors so I took it, there is some right way to use or just put the "i" in front of msql?
4 - I searched on the internet and put in the field of image that it is type LONGBLOB is the best alternative?
BRING BACK THE DATABASE
<?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;
    }       
}
?>
INSERTS THE DATA INTO THE DATABASE
<?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 updated the code below and now there is no error only that in 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>  
						
gives a print_r or var_dump in $image to see the type of the variable
– Adir Kuhn
Another thing that by your script is saving an array of $_FILE and not the contents of the image
– Adir Kuhn
Line 14 is which?
– rray
@rray line 14 is this $inserts = mysql_query("INSERT INTO formulary (name, age, phone, editor1, image) VALUES ('$name', '$age', '$phone', '$editor1', '$image' )");
– Estenio Ribeiro Nobrega
That answer might help you how to use the
mysqliin the right way– DNick