I need a little help to an error with my PhP code.
I have a website, that work as a company website and a online store.
The Idea is that the Admin can make custom database row, in order to generate through a PhP script a custom page that show to the user the product info.
The problem i that my PhP code Just fail when uploading the script into the database, the error that show up is just chrome saying "This page isn’t working, localhost is currently unable to handle this request.
HTTP ERROR 500"
I have do many research in web and here on StackOverflow, but nothings work's.
<?php
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$db_connect = mysqli_connect('localhost', $username, $password, 'cosipi');
if(!$db_connect) {
session_unset();
session_destroy();
exit('Non sei autorizzato ad accedere a questa pagina.');
}
$file = $_FILES['image']['tmp_name'];
$image = file_get_contents($_FILES['image']['tmp_name']);
$image_name = $_FILES['image']['name'];
$sql = "INSERT INTO products ('','name','description','photo') VALUES ('', 'nome foto','descrizione','12','');";
$query = mysqli_query($db_connect, $sql);
mysqli_close ($db_connect);
?>
I have even followed a video tutorial to try make this work, but it just won't.
Here is the HTML form code.
<form action="/new_product.php" method="post" enctype="multipart/form-data">
<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input type="file" name="image" value="Photo" accept="image/jpg" /><br /><br />
<input type="submit" value="Save" />
</form>
MySql database have a specific column named "photo" with type "longblob".
I'm not the best with PHP and usually i don't work with photos on form and mysql database.
Any help would be appreciated, thank's.
-EDIT-
Fixed some Syntax and the mixed API problem, still not working.