Warning notices and syntax errors

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 = mysqli_connect (“localhost”, “rupert”, “” );
$db = mysqli_select_db(“imagestore”,$conn);
if(!$db)
{
echo mysqli_error();
}

$query = “INSERT INTO animaldata VALUES (’’, ‘$aname’, ‘$adetails’, ‘$aphoto’,’$imgtype)”;
mysqli_query($query,$conn);
$results = mysqli_query($query,$conn);
if( $results )
{
echo “Information Stored Successfully”;
}
else
{
echo mysqli_error();
}

}
?>

HTML

Animal Information

 

Animal 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…

DUPLICATE POST!

You do realise posting the same question in another section won’t get you helped any quicker?

I have tried to help you in this post

The reason I didn’t ‘solve’ your question for you was you said you’d changed from mysql to mysqli. The code you posted suggests you went through adding an i on the end - which in turn means you don’t quite grasp it just yet, same with $_FILES (as opposed to file_get_contents).

If you read the links i posted in that question, i’m pretty sure you’d have had this figured out by now.
Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service