Hello all,
I'm going through some PHP scripts and I can't figure out some stuffs in there, the script is used to update a blob field in a mysql table.
Below are the Mysql table and the PHP scripts:
DROP TABLE Blobtab;
CREATE TABLE Blobtab
( blob_id INTEGER AUTO_INCREMENT PRIMARY KEY,
blob_data LONGBLOB,
fdescription CHARACTER VARYING(50),
filename CHARACTER(25),
filesize CHARACTER(25),
filetype CHARACTER(25)
);
the PHP script
<?php
$session = mysql_connect("localhost", "", "");
mysql_select_db("ee3103");
$fd = fopen($form_data, "rb");
$data = addslashes(fread($fd, filesize($form_data)));
$query = "INSERT INTO Blobtab(blob_data, fdescription, filename, filesize, filetype) " .
"VALUES ('$data', '$form_description', '$form_data_name', '$form_data_size', '$form_data_type')";
$result = mysql_query($query);
if ( !$result )
{
echo ( "<P>Error performing INSERT: " . mysql_error() . "</P>" );
}
else
{
$blobid = mysql_insert_id();
print "<P>This file has the following BLOB ID: <B>$blobid</B>";
}
fclose($fd);
mysql_close($session);
?>
I am confused about the $fd and what its for, can anyone help me out here