Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
BLOBing Microsoft Excel Data
Old 08-11-2007, 07:35 PM BLOBing Microsoft Excel Data
Average Talker

Posts: 24
Trades: 0
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
FuZion is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-12-2007, 01:45 AM Re: BLOBing Microsoft Excel Data
brandrocker's Avatar
Experienced Talker

Posts: 30
Name: CONFIDENTIAL
Location: India
Trades: 0
Table name (service_sheets) is missing in mySQL Query.

This works fine.

Code:
INSERT INTO service_sheets ( aid, date, number, xls_data ) 
VALUES ( 1, STR_TO_DATE( '07/08/2008', '%m/%d/%Y' ) , 1, "BLOB CODE HERE" )
Hope this helps.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
brandrocker is offline
Reply With Quote
View Public Profile Visit brandrocker's homepage!
 
Old 08-12-2007, 11:34 AM Re: BLOBing Microsoft Excel Data
Average Talker

Posts: 24
Trades: 0
Thats, correct, but that is a mistake on my end. I tend to think less when I get frustrated .

I wrote a few functions to use with mysql.. and in the query function it uses regex to find <table nickname> and it references an array to find the actual table name and replaces it. That is why there was nothing in there. I have, however, been adding it in my queries. I can't believe I forgot it here.. I need to take a break.

Anywho, the error is the same with the table in there.. but it has some of the blob data in there. Could it be the file I'm uploading?
FuZion is offline
Reply With Quote
View Public Profile
 
Old 08-12-2007, 12:11 PM Re: BLOBing Microsoft Excel Data
Average Talker

Posts: 24
Trades: 0
Would it help if I posted a query with the data in it?
FuZion is offline
Reply With Quote
View Public Profile
 
Old 08-13-2007, 12:00 PM Re: BLOBing Microsoft Excel Data
Average Talker

Posts: 24
Trades: 0
Turns out the php file was in DOS format, not UNIX format which was causing some problems. Everything is working fine now.
FuZion is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to BLOBing Microsoft Excel Data
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14728 seconds with 12 queries