1

I have a form and code to upload the info and an image. Everything is working, the image is getting resized and placed in the correct folder. After that I have code to insert the info into the database.

$query = "INSERT INTO `artigos` VALUES ('','$titulo','$nome','$corpo','$categoria','','')";

$result = mysqli_query($con, $query);

//se a query existe entao a pagina é redireccionada

if (mysqli_affected_rows($con) != 0)
{
    $sucesso = '<span  class="yes">Artigo inserido com sucesso!</span>';
    echo $sucesso;
}

I get the message "Artigo inserido com sucesso" but the info doesn't appear in the database. MY $con is the mysqli connect. All the variables exist, I get no error when I press the button, but the info doesn't go to the database. My 'artigos' table contains these fields:

id_artigo, titulo, img, corpo, id_categoria, id_user, date(timestamp).

What is wrong?

mhatch
  • 4,441
  • 6
  • 36
  • 62
user3375665
  • 73
  • 1
  • 2
  • 9

1 Answers1

-1

Try this:

<?php
 $query = "$query = "INSERT INTO artigos(titulo, img, corpo, id_categoria,id_user) VALUES ('{$titulo}','{$nome}','{$corpo}',{'$categoria'}, 4";";

$result = mysqli_query($con, $query);

//se a query existe entao a pagina é redireccionada

if (mysqli_affected_rows($con)!=0)

{

$sucesso = '<span  class="yes">Artigo inserido com sucesso!</span>';

echo $sucesso;

}

?>
lyndact
  • 1
  • 3
  • 23