Hello,
I am having a problem BLOBing a Microsoft Excel file into a database. Here is the code I am using..
Code:
$svcSheetHandler = fopen ( $_FILES['svcSheet']['tmp_name'], "r" );
$svcSheetContent = fread( $svcSheetHandler, $_FILES['svcSheet']['size'] );
$svcSheetContent = addslashes ( $svcSheetContent );
fclose ( $svcSheetHandler );
I have used this exact same code many times before with no problems, but this time it does not work. If I remove the BLOB part of it, then the query runs fine. When I try to run the query in MySQL query browser the blob field is not rendered as a string, I can tell because it is not highlighted the normal string color.
I get this 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 '( aid, date, number, xls_data ) VALUES ( 1, STR_TO_DATE('07/07/2007', '%m/%d/%Y'' at line 1
For this SQL:
Code:
INSERT INTO ( aid, date, number, xls_data ) VALUES ( 1, STR_TO_DATE('07/08/2008', '%m/%d/%Y'), 1, "BLOB CODE HERE" )
Here is my table structure:
Code:
CREATE TABLE `service_sheets` (
`ssid` int(10) unsigned NOT NULL auto_increment,
`aid` int(10) unsigned NOT NULL default '0',
`date` date NOT NULL default '0000-00-00',
`number` int(11) default NULL,
`xls_data` blob NOT NULL,
`pdf_data` blob NOT NULL,
PRIMARY KEY (`ssid`),
KEY `aid_fk` (`aid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I can post the blob code if it is necessary but it is very long so I decided to leave it out.
I have been working hard at this and I cannot seem to figure out what is wrong.
Thanks in advance for your help,
FuZion