RajaGautam
Registered User.
- Local time
- Today, 20:09
- Joined
- Apr 5, 2013
- Messages
- 10
I have two php extension code one for form input & another for upload to MySql database management system. The form input code is as below:
denoted by "main.php"
<html>
<title>Animal Information</title>
<body>
<form enctype="multipart/form-data" action="storeinfo.php" method="POST">
<table border=0 align=center bgcolor=black width=100%>
<tr>
<td colspan=2><h2> </h2></td>
</tr>
</table>
<table border=0 align=center bgcolor=grey>
<tr>
<td cospan=2><h2>Animal Information</h2></td>
</tr>
<tr>
<td>Animal Name</td><td><input type=text name="aname"></td>
</tr>
<tr>
<td>Animal Description</td><td><input type=text name="adetails"></td>
</tr>
<tr>
<td>Animal Photo</td><td><input type=file name="aphoto"></td>
</tr>
<tr>
<td></td><td><input type=submit name="submit" value="Store Information"></td>
</tr>
</table>
</form>
</body>
</html>
There is no error in this above code
The upload code is as below:
denoted by "storeinfo.php"
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysql_connect("localhost","root","");
if(!$conn)
{
echo mysql_error();
}
$db = mysql_select_db("imagestore",$conn);
if(!$db)
{
echo mysql_error();
}
$aname = $_POST['aname'];
$adetails = $_POST['adetails'];
$aphoto = addslahes(file_get_contents($_FILES['aphoto']['tmp_name']));
$image = getimagesize($_FILES['aphoto']['tmp_name"]);//to know about iamge type
$imgtype = $image['mime'];
$q="INSERT INTO animaldata VALUES('','$aname','$adetails','$aphoto','$imgtype')";
$r = mysql_query($q,$conn);
if($r)
{
echo "Information stored successfully";
}
else
{
echo mysql_error();
}
?>
When i fill up all Animal Information section and browse for image & click on summit button it display the error as below:
Parse error: syntax error, unexpected 'mime' (T_STRING), expecting ']' in C:\xampp\htdocs\php\storeinfo.php on line 18
line 18: $imgtype = $image['mime'];
The image file size is 34.8KB. I have managed my PhpMyAdmin database name databaseimage with proper data & validity entries.
My Php version is 5.4.7, SQL version is 5.5.27. Why 'mime' is unexpected ? Please help me to solve it.
denoted by "main.php"
<html>
<title>Animal Information</title>
<body>
<form enctype="multipart/form-data" action="storeinfo.php" method="POST">
<table border=0 align=center bgcolor=black width=100%>
<tr>
<td colspan=2><h2> </h2></td>
</tr>
</table>
<table border=0 align=center bgcolor=grey>
<tr>
<td cospan=2><h2>Animal Information</h2></td>
</tr>
<tr>
<td>Animal Name</td><td><input type=text name="aname"></td>
</tr>
<tr>
<td>Animal Description</td><td><input type=text name="adetails"></td>
</tr>
<tr>
<td>Animal Photo</td><td><input type=file name="aphoto"></td>
</tr>
<tr>
<td></td><td><input type=submit name="submit" value="Store Information"></td>
</tr>
</table>
</form>
</body>
</html>
There is no error in this above code
The upload code is as below:
denoted by "storeinfo.php"
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysql_connect("localhost","root","");
if(!$conn)
{
echo mysql_error();
}
$db = mysql_select_db("imagestore",$conn);
if(!$db)
{
echo mysql_error();
}
$aname = $_POST['aname'];
$adetails = $_POST['adetails'];
$aphoto = addslahes(file_get_contents($_FILES['aphoto']['tmp_name']));
$image = getimagesize($_FILES['aphoto']['tmp_name"]);//to know about iamge type
$imgtype = $image['mime'];
$q="INSERT INTO animaldata VALUES('','$aname','$adetails','$aphoto','$imgtype')";
$r = mysql_query($q,$conn);
if($r)
{
echo "Information stored successfully";
}
else
{
echo mysql_error();
}
?>
When i fill up all Animal Information section and browse for image & click on summit button it display the error as below:
Parse error: syntax error, unexpected 'mime' (T_STRING), expecting ']' in C:\xampp\htdocs\php\storeinfo.php on line 18
line 18: $imgtype = $image['mime'];
The image file size is 34.8KB. I have managed my PhpMyAdmin database name databaseimage with proper data & validity entries.
My Php version is 5.4.7, SQL version is 5.5.27. Why 'mime' is unexpected ? Please help me to solve it.
