My table:
CREATE TABLE forum (
id bigint(20) NOT NULL auto_increment,
subject varchar(100) NOT NULL default '',
username varchar(16) NOT NULL default '',
message text NOT NULL,
the_file mediumblob,
mime varchar(50) default NULL,
date_submit datetime NOT NULL default '0000-00-00 00:00:00',
date_replied timestamp(14) NOT NULL,
replyid bigint(20) NOT NULL default '0',
replys int(11) NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id)
) TYPE=MyISAM;
if($reply == 0 and $image="true"){
//user has successfully posted a new thread now go back to the forum
$the_file = file_get_contents($_FILES['userfile']['tmp_name']);
$filetype=$_FILES['userfile']['type'];
$sql = "INSERT INTO forum (id, subject, username, message, the_file, mime, date_submit, replyid) VALUES ('', '$subject', '$username', '$message','$the_file','$filetype', NOW(), '".$reply."')";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
header("Location: ./forum.php");
exit();}
When I try to insert into the database I get a mysql error.
I know the syntax is okay. If I take out $the_file (See below) out of the insert statement it works fine.
if($reply == 0 and $image="true"){
//user has successfully posted a new thread now go back to the forum
$the_file = file_get_contents($_FILES['userfile']['tmp_name']);
$filetype=$_FILES['userfile']['type'];
$sql = "INSERT INTO forum (id, subject, username, message, mime, date_submit, replyid) VALUES ('', '$subject', '$username', '$message','$filetype', NOW(), '".$reply."')";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
header("Location: ./forum.php");
exit();}
As soon as I put $thefile into the statement I get the following mysql error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'HÅÅ?ey]z”ÝÞáËÌ?|ŒGh„y¤áâ?¥·—˜šèéí' at line 1
Also when I echoed out $thefile I get the file I browsed. So it is set. So Im wondering if it has something to do with file-directory permissions, my Internet service provider, or my version of mysql. I'm lost....
Please Help Thanks..