Hi All,
This is my first post on here. I'd really appreciate any help with this, it's driving me mad.
I'm trying to create a form to save a image into a mySQL database.
I have a website hosted by UK2.net which has a mysql db with a table called gallery(name (varchar 30), size (int), type varchar(30), thePic(mediumBlob)).
I have a form with this:
<td><p><label>Pic: </label></td><td><input name="userfile" type="file" id="userfile" /></td></p>
Which when submitted actions addImage.php. The code for this looks like this:
<?php
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$con = mysql_connect("localhost", "userName", "password") or die(mysql_error());
mysql_select_db("dbName", $con) or die(mysql_error());
$query = "INSERT INTO gallery (name, size, type, thePic) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
if (!mysql_query($query,$con))
{
die('Error: ' . mysql_error());
}
echo "<br>File $fileName uploaded<br>";
?>
I get the following error message:
Does anyone know what this is about? I've been on out friend google and a lot of people seem to be pointing to permissions but I can't seem to apply it to my scenario and just can't get it to work. Im a developer by trade, but this is my first step into the...interesting world of PHP and mySQL.
Again, I'd appreciate any help with this. I'd love someone to talk me through exactly what I'm missing or doing wrong.
Thanks in advance.