Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

foxpro and sql

Status
Not open for further replies.

ber019

Programmer
Joined
Apr 2, 2001
Messages
2
Location
AT
hi!
normally i use php and script languages for programming but i need you help, what's wrong with the source code below? the function memoread gives the file(jpeg) back and i want to save it in mysql. Daten is a longblob and name ist char(40).

?sqlcon("scanner")
MODIFY COMMAND C:\Programme\vfp\MEMOREAD.PRG
inhalt=memoread('klein.jpg')
?inhalt //gives silly source back what'S normal
?sqlexec(1,"insert into container (daten,name) values (inhalt,'klein.jpg')")

my second question is how i can get the mime typ of a file for storing it in mysql like plain/text or image/pjpeg?

thx
michi
 
If your problem is that the line
Code:
inhalt=memoread('klein.jpg')
doesn't give the result you expect (ie a blob containing the jpeg) then we'd probably need to see the contents of C:\Programme\vfp\MEMOREAD.PRG to spot the error.

Chris
 
ok thanks for taking time- here the code:

*Procedure MemoRead
parameter IFile

set talk off

if !file(IFile)
return ""
endif

hdl= FOPEN(IFile,0)
Fsize= FSEEK(hdl,0,2)
=FSEEK(hdl,0)
OTxt= FREAD(hdl,Fsize)
=fclose(hdl)
return OTxt

thx
michi
 
Drop the line MODIFY COMMAND... and see if your results improve.

I don't know about MySQL, but some databases (such as MS SQL Server) won't accept a BLOB in this manner. Robert Bradley
teaser.jpg

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top