Hello,
I just wrote a script and an HTML code to insert a a record with 2 blob files (1 movie and 1picture) into a mysql table, each time I try to load data into the table I always have these lines of error message:
Warning: fread(): supplied argument is not a valid stream resource in d:\phpweb\store.php on line 5
This product has the following code:1
Warning: fclose(): supplied argument is not a valid stream resource in d:\phpweb\store.php on line 19
and then it will go ahead and update the table, but whenever i try to view the record the columns in the table are always blank but the itemcode which is auto increment will be updated accordingly some please help before I hang myself.
Here's the PHP script:
<?php
$session = mysql_connect("localhost", "root", "platinum");
mysql_select_db("xplosive");
$fd = fopen($form_data, "r");
$data = addslashes(fread($fd, filesize($form_data)));
$query = "INSERT INTO movies(title, genre, trailer, synopsis, tfilename, tfilesize, tfiletype, picture, pdescription, pfilename, pfilesize, pfiletype, price) ".
"VALUES ('$title', '$genre', '$data', '$synopsis', '$form_data_name', '$form_data_size', '$form_data_type', '$data', '$pdescription', '$pform_data_name', '$pform_data_size', '$pform_data_type', '$price')";
$result = mysql_query($query);
if (!$result )
{
echo ( "<p> ERROR: DATA NOT INSERTED: " .mysql_error() . "</p>" );
}
else
{
$Itemcode = mysql_insert_id();
print "<p>This product has the following code:<B>$Itemcode</B>";
}
fclose($fd);
mysql_close($session);
?>
and here's my html code:
<HTML>
<HEAD>
<TITLE>STORE MOVIE</TITLE>
</HEAD>
<BODY>
<FORM method="post" action="store.php" enctype="multipart/form-data">
<p>Title: <BR>
<input type="text" name="title" size="70"> </p>
<p>Genre: <BR>
<input type="text" name="genre" size="25"> </p>
<p>Synopsis: <BR>
<textarea name = "synopsis" rows = "6" cols = "n" size="250">
</textarea>
</p>
<p>Trailer to store in database: <BR>
<input type="file" name="form_data" size="45">
<input type="hidden" name="max_file_size" value="1073741824">
</p>
<p>Picure: <BR>
<input type="file" name="pdescription" size="45">
<input type="hidden" name="max_file_size" value="1073741824">
</p>
<p>Price: <BR>
<input type="text" name="price" size="20">
</p>
<input type="submit" name="submit" value="Submit"
</FORM>
</BODY></HTML>