ho i'm a newbie trying to upload images into a mysql database, using the code posted in an article on here by _Florian Dittmer , updated for php4.32 by Patrick Kebekus
the error is
Parse error: parse error in /hsphere/local/home/haydn/twocreate.pipeten.com/new/upload.php on line 24, which is this line
$data = addslashes(fread(fopen($FILES['form_data']['tmp_name'], "r"), $_FILES['form_data']['size']));
this is the full code, thanks for your help
<?php
// store.php - by Florian Dittmer <dittmer@gmx.net>
// moded for php4 by Patrick.MKC@gmx.de
// Example php script to demonstrate the storing of binary files into
// an sql database. More information can be found at http://www.phpbuilder.com/
?>
<HTML>
<HEAD><TITLE>Store binary data into SQL Database</TITLE></HEAD>
<BODY>
<?php
// code that will be executed if the form has been submitted:
if (isset($_REQUEST['submit'])) {
// connect to the database
// (you may have to adjust the hostname,username or password)
_MYSQL_CONNECT("localhost","haydn_dba","password");
mysql_select_db("haydn_content");
__$data = addslashes(fread(fopen($FILES['form_data']['tmp_name'], "r"), $_FILES['form_data']['size']));
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) ".
"VALUES ('".$form_description."','".$data."','".$FILES['form_data']['name']."','".$FILES['form_data']['size']."','".$_FILES['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:
?>
<form method="post" action="store.php" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
</BODY>
</HTML>