0

Im trying to insert this information but im getting this error:

Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in /storage/ssd2/324/18431324/public_html/processoadicionarcarros.php:248 Stack trace: #0 {main} thrown in /storage/ssd2/324/18431324/public_html/processoadicionarcarros.php on line 248

Here is my code for inserting:

    $iduser = $_SESSION['iduser'];

    $query = "INSERT INTO carros (marca, modelo, submodelo, combustivel, mesReg, anoReg, quilometros, cilindrada, potencia, aceitaRetoma, cor, tipoCor, tipoCaixa, nPortas, lotacao, nMudancas, registo, origem, livroRevisoesCompleto, naoFumador, segundaChave, anunciante, imagemPrincipal, imagemPrincipalLoc, imagemUm, imagemUmLoc, imagemDois, imagemDoisLoc, imagemTres, imagemTresLoc, imagemQuatro, imagemQuatroLoc, imagemCinco, imagemCincoLoc, imagemSeis, imagemSeisLoc, imagemSete, imagemSeteLoc, userid) VALUES (UPPER(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))";
    $stmt = $mysqli -> prepare($query);
   **line 248 -** $stmt -> bind_param("sssssiiiissssiiiisssssssssssssssssssssi", $marca, $modelo, $submodelo, $combustivel, $mesReg, $anoReg, $quilometros, $cilindrada, $potencia, $acRetoma, $cor, $tipoPintura, $tipoCaixa, $nPortas, $lotacao, $nMudancas, $registo, $origem, $livroRevisoes, $fumador, $segChave, $anunciante, $imgPrincipalNewName, $imgPrincipalDestino, $imagemUmNewName, $imagemUmDestino, $imagemDoisNewName, $imagemDoisDestino, $imagemTresNewName, $imagemTresDestino, $imagemQuatroNewName, $imagemQuatroDestino, $imagemCincoNewName, $imagemCincoDestino, $imagemSeisNewName, $imagemSeisDestino, $imagemSeteNewName, $imagemSeteDestino, $iduser);
    $stmt -> execute();
    $stmt -> close();

Database photo:

enter image description here

If someone could help me with this I would really appreciate it.

Edit: If I remove UPPER it works, I just dont understand what is wrong with UPPER, can someone explain please ?

7
  • Does this answer your question? How to deal with mysqli problems? mysqli_fetch_array(): Argument #1 must be of type mysqli_result Commented May 29, 2022 at 0:35
  • If you bothered to check for errors you'd know that your prepare has failed, and why. Take a look at the correct syntax for UPPER() Commented May 29, 2022 at 0:38
  • I dont understand, what is wrong with UPPER() can you tell me if you dont mind please ? Commented May 29, 2022 at 1:05
  • Hi @MiguelF, it can only accept one parameter, looks like you're passing multiple. Commented May 29, 2022 at 2:10
  • 1
    No worries, click the tick next to your answer to accept it. :) Commented May 29, 2022 at 2:24

1 Answer 1

1
$query = "INSERT INTO carros (marca, modelo, submodelo, combustivel, mesReg, anoReg, quilometros, cilindrada, potencia, aceitaRetoma, cor, tipoCor, tipoCaixa, nPortas, lotacao, nMudancas, registo, origem, livroRevisoesCompleto, naoFumador, segundaChave, anunciante, imagemPrincipal, imagemPrincipalLoc, imagemUm, imagemUmLoc, imagemDois, imagemDoisLoc, imagemTres, imagemTresLoc, imagemQuatro, imagemQuatroLoc, imagemCinco, imagemCincoLoc, imagemSeis, imagemSeisLoc, imagemSete, imagemSeteLoc, userid) VALUES (UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?))";

instead of:

$query = "INSERT INTO carros (marca, modelo, submodelo, combustivel, mesReg, anoReg, quilometros, cilindrada, potencia, aceitaRetoma, cor, tipoCor, tipoCaixa, nPortas, lotacao, nMudancas, registo, origem, livroRevisoesCompleto, naoFumador, segundaChave, anunciante, imagemPrincipal, imagemPrincipalLoc, imagemUm, imagemUmLoc, imagemDois, imagemDoisLoc, imagemTres, imagemTresLoc, imagemQuatro, imagemQuatroLoc, imagemCinco, imagemCincoLoc, imagemSeis, imagemSeisLoc, imagemSete, imagemSeteLoc, userid) VALUES (UPPER(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))";

Because UPPER() can only accept one parameter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.