In a MYSQL DB table I have a description and an image. The image is a BLOB. I directly put the image in the DB, the image is a JPG file. In Livecode I have to retrieve the image from the DB and display it in an image Area on the stack.
There are no errors in the code and while debugging I can see that the binary data is being retrieved, but it does not display in the image area ("imgBox").
Code: Select all
on mouseUp
## Connect to the database
put "mysql" into theDBType
put "127.0.0.1:3306" into theDBHost
put "traffic" into theDBName
put "root" into theDBUser
put "root" into theDBPassword
put revOpenDatabase( theDBType, theDBHost, theDBName, theDBUser, theDBPassword ) into theConnectionID
if theConnectionID is an integer then
## Query the database for data
put "SELECT * FROM signs where idsigns ='1'" into tQuery
put revQueryDatabase( theConnectionID, tQuery, "tIndex") into theCursor
if theCursor is not empty then
//take the desc from the Query result
put revDatabaseColumnNamed(theCursor, "desc") into tDesc
//Show the dec in the TextBox
put tDesc into field "imgDesc"
//take the image from the Query result
put revDatabaseColumnNamed(theCursor, "signimg", "tImageData") into tErrorMsg
//Show the image in the imageBox
put base64decode(tImageData) into theImage
set the text of image "imgBox" to theImage
show image imgBox
else
answer "Error Cursor: Reading from DB"
end if
//Close the Cursor with Query Result
revCloseCursor theCursor
else
answer "Error connecting to the database:" && theConnectionID & "."
end if
//Close the DB Connection ID
revCloseDatabase theConnectionID
end mouseUp
Thank you for the help.