Search an image in a Mysql database with php and then save that image to another table in the same database

Asked

Viewed 397 times

-2

I am making an application to save images, when the user does not choose any image is saved in the database a default image that is selected in another table of the database, but when saving the image in the database, php returns the following error:

You have an error in your SQL syntax; check the manual that Corresponds to your Mariadb server version for the right syntax to use near ',,,,,'??? ' at line 1

Follow the code that searches the image in the bank and that displays it:

Seeking:

    $query = "select imagem from imagem_padrao";
    $imagem_padrao = mysqli_query($con,$query);
    $imagem_padrao = mysqli_fetch_row($imagem_padrao);
    $imagem_pronta = $imagem_padrao[0];

Insert:

   $query = ("insert into tamanho (foto_aparelho) values ('".$imagem_pronta."')");
   mysqli_query($con,$query) or die (mysqli_error($con); 

I believe that the error is happening when inserting the image in array format in the database, but I do not know how to solve.

  • I think the problem is how you are defining the query, change the $query = ("insert into tamanho (foto_aparelho) values ('".$imagem_pronta."')"); for $query = "insert into tamanho (foto_aparelho) values ('".$imagem_pronta."')";, removing the first ( and last ).

  • Sorry the error is not in the syntax of Insert, this is a typo of mine, I will edit the post.

  • 1

    You have to enter the code correctly because we often see people breaking their heads and the error is exactly in typing the code.

1 answer

0

I solved the problem otherwise, instead of storing the default photo in a database table, I left it as an image file inside the application server folder, hence it worked as expected.

Browser other questions tagged

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