Urgent help needed in solving these sql syntax errors and warning notices on how to upload an image file into a database Thank you… Below are my Html pages,Php Code and Database script…
PHP
Animal <?php if (isset($_POST["submit"])) {$aname = $_POST[“aname”];
$adetails = $_POST[“adetails”];
$aphoto = addslashes (file_get_contents($_FILES[“aphoto”][“tmp_name”]));
$image = getimagesize($_FILES[“aphoto”][“tmp_name”]);//to know about image type etc//
$imgtype = $image[‘mime’];
$conn = mysql_connect (“localhost”, “rupert”, “” );
$db = mysql_select_db(“imagestore”,$conn);
if(!$db)
{
echo mysql_error();
}
$query = “INSERT INTO animaldata VALUES (’’, ‘$aname’, ‘$adetails’, ‘$aphoto’,’$imgtype)”;
mysql_query($query,$conn);
$results = mysql_query($query,$conn);
if( $results )
{
echo “Information Stored Successfully”;
}
else
{
echo mysql_error();
}
}
?>
HTML
Animal InformationAnimal Information | |
Animal Name | |
Animal Description | |
Animal Photo | |
DATABASE
– phpMyAdmin SQL Dump
– version 3.5.2.2
– http://www.phpmyadmin.net
– Host: 127.0.0.1
– Generation Time: Nov 11, 2014 at 09:29 AM
– Server version: 5.5.27
– PHP Version: 5.4.7
SET SQL_MODE=“NO_AUTO_VALUE_ON_ZERO”;
SET time_zone = “+00:00”;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/!40101 SET NAMES utf8 */;
–
– Database: imagestore
–
– Table structure for table animaldata
CREATE TABLE IF NOT EXISTS animaldata
(
ano
int(5) NOT NULL AUTO_INCREMENT,
aname
varchar(200) NOT NULL,
adetails
text NOT NULL,
aphoto
blob NOT NULL,
aphototype
varchar(200) NOT NULL,
PRIMARY KEY (ano
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘Aniamal Information Table’ AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /;
/!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
AND THE CORRESPONDING ERRORS ARE AS FOLLOWS:
Warning: file_get_contents(): Filename cannot be empty in C:\xampp\htdocs\Databasefoto\storeinfo.php on line 15
Warning: getimagesize(): Filename cannot be empty in C:\xampp\htdocs\Databasefoto\storeinfo.php on line 16
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’)’ at line 1
Any help will be of great importance to me…