I am trying to create a basic form to list inventory on a website using PHP and MySQL. I keep getting errors when I follow some of the guides here on stackoverflow. Any help would be greatly appreciated.
My question is: My insert statement keeps failing when I use it through the PHP form but when I do it through phpMyAdmin it works. How do I figure out where my error is and how do i solve it.
Form:
<form action="add.php" method="post" enctype="multipart/form-data">
Item Type: <input type="text" name="type" /><br>
Description: <input type="text" name="description"/><br>
Price: <input type="text" name="price" /><br>
Date: <input type="text" name="date" /><br>
Pic:<input type="file" name="image"> <br/>
<input type="submit" >
</form>
add.php:
<?php
$type = $_POST['type'];
$desc = $_POST['description'];
$price = $_POST['price'];
$date = $_POST['date'];
$file = $_FILES['image']['tmp_name'];
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_size = getimagesize ($_FILES['image']['tmp_name']);
$host = "localhost";
$user = "root";
$password = "";
$cnn = mysql_connect ( $host, $user, $password );
mysql_select_db('inventory');
$insert = mysql_query("INSERT INTO 'newitems' ('ID', 'ItemType', 'Description', 'Price', 'Date', 'Pic')VALUES ('','$type','$desc','$price','$date', '{$image}')");
if (!mysql_query($insert)) {
echo "Something went wrong! :(";
echo '<img src="data:image/jpeg;base64,' . base64_encode( $image ) . '" />';
}
?>