Array to a String Conversion

Asked

Viewed 150 times

0

I don’t know how to solve this problem:

Notice: Array to string Conversion in C: Bitnami wampstack-5.6.19-0 apache2 htdocs noivosDAO.php on line 12

dao file:

function insereNoivos ($noivos) {

  $query = "insert into noivos (nome1, sobrenome1, email, nome2, sobrenome2,
            telefone , rua, numero, cep, cidade, foto) values ('{$noivos->getNome1()}', '{$noivos->getSobrenome1()}', '{$noivos->getEmail()}', '{$noivos->getNome2()}','{$noivos->getSobrenome2()}', {$noivos->getTelefone()}, '{$noivos->getRua()}', '{$noivos->getNumero()}', '{$noivos->getCep()}', '{$noivos->getCidade()}', {$noivos->getFoto()})";

  return mysqli_query($this->conexao, $query);
}

file Adds:

<?php
$noivos = new Noivos();
$noivos->setNome1($_POST["nome1"]) ;
$noivos->setSobrenome1($_POST["sobrenome1"]);
$noivos->setEmail($_POST["email"]);
$noivos->setNome2($_POST["nome2"]);
$noivos->setSobrenome2($_POST["sobrenome2"]);
$noivos->setTelefone($_POST["telefone"]);
$noivos->setRua($_POST["rua"]);
$noivos->setNumero($_POST["numero"]);
$noivos->setCep($_POST["cep"]);
$noivos->setCidade($_POST["cidade"]);
$noivos->setFoto($_FILES["foto"]);
  • 1

    $_FILES["photo"] is an array, if you have tried to store it directly in the database this is the error. If so, read more in the documentation how to properly store the file data.

  • Mellhor vc store the photo in a folder. the folder name could be the user ID. Ai in the bank you save only the file name

  • thanks Anderson I will see the documentation.

  • Thank you Israel, I’m trying to do just that, the folder is img and it will store the photos with a name extension in the BD.

No answers

Browser other questions tagged

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