I want to store an image in my database.
I found an article in http://www.phpbuilder.com/columns/florian19991014.php3?page=2
So I created a table.
CREATE TABLE `binary_data` (
`id` int(4) NOT NULL auto_increment,
`gedcom` varchar(15) default NULL,
`doctype` char(2) default NULL,
`bin_data` longblob,
`filename` varchar(50) default NULL,
`filesize` varchar(50) default NULL,
`filetype` varchar(50) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
Then copies the script from the site and made some small adjustments in names.
<?php
if ($submit) {
MYSQL_CONNECT("localhost","user","pw");
mysql_select_db("db");
$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
$result=MYSQL_QUERY("INSERT INTO binary_data (gedcom, doctype, bin_data,filename,filesize,filetype) ".
"VALUES ('$gendoc','$doctype','$data','$form_data_name','$form_data_size','$form_data_type')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
?>
<table width="50" border="0">
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<tr><td>Gedcom:</td></tr>
<tr><td><input type="text" name="gedcom" size="15"></td></tr>
<tr><td>Document typy:</td></tr>
<tr><td><input type="text" name="doctype" size="2"></td></tr>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<tr><td><br>Bestand/File:</h5> </td></tr>
<tr><td><input type="file" name="form_data" size="80"></td></tr>
<tr><td><p><input type="submit" name="submit" value="submit">
</form>
</table>
<?php
}
?>
It doesn't even print "This file has the following Database ID: ", so it looks it does n't go to the $submit loop
What am I doing wrong??