This topic is locked

Displaying images

8/10/2016 10:21:31 AM
PHPRunner General questions
P
PHPRunnerExplorer author

Hi,
I tried to avoid asking on the forum, because this should be obvious, but after several days of trying and reading through the Help, I can't display jpg images in the Edit or View Screen.
We have the varbinary field in Sql Server defined, as well as a varchar name field for the filename. But after we Choose a file, and Save, the Edit Screen still says Choose File/No file chosen. The software doesn't prompt us for a filename, to put in the filename field. The binary image itself, DOES get saved in the varbinary field.
We don't need to use thumbnails. We would prefer to display the images on the Edit and View pages, but would be satisfied with a link that would display the image in a popup or a separate page.
Sorry if this should be obvious, but I just can't figure this out. We can do it with some custom code, but we'd like to make full use of PHPRunner's capabilities.
I should also mention some confusion about one of the Help Screens. At the bottom of
Visual Editor - "Edit as" settings: File/Image"
of 8.1, there is a section
Binary Field: File
, and it says to choose a field that stores the name of a 'database file'. I don't understand what database file they are talking about. We are using Microsoft Sql Server; do they mean the server name? Is there an external database of images or file names that we should be using? Really sorry, but I can't make any sense of this.

Sergey Kornilov admin 8/11/2016

'database file' - this is your file that is stored in the database, in field like VARBINARY.
Name of a 'database file' - is the name of your file. You need to select a text field that belongs to the same table to store the name of the file. Without a name your file is just a set of bytes, you cannot tell if this a DOC or PDF or JPG file.

P
PHPRunnerExplorer author 8/11/2016

Thanks admin,
"database file' - this is your file that is stored in the database, in field like VARBINARY."
You mean, the binary image file, extracted from the contents of the actual jpg? Ok.
""Name of a 'database file' - is the name of your file. You need to select a text field that belongs to the same table to store the name of the file. Without a name your file is just a set of bytes, you cannot tell if this a DOC or PDF or JPG file."
Yep, I have that text field.
Before you responded, we went ahead and implemented Thumbnails for one of the images, after throwing in a Binary field in Sql Server, for the thumbnail. Also, we shifted everything to PHPRunner 9.
It almost works perfectly, except for the (Keep/Delete/Update) radio buttons. How do we get rid of those, and get the program to understand that the image in the varbinary field, is valid?
Hmmm. I'm getting a Sql Error, when we run it on the server, Choose a file and then Save, that a String or binary data would be truncated. This doesn't happen when running it with PHPRunner's internal server. It's the same database - varchar(50) for the filename, varbinary for the image, binary for the thumbnail.
Yikes. Also, when we View the list of existing records from the PHPRunner internal server, it shows the thumbnails for that field. When we run it from the server, they don't show up; the fields are just blank.



'database file' - this is your file that is stored in the database, in field like VARBINARY.
Name of a 'database file' - is the name of your file. You need to select a text field that belongs to the same table to store the name of the file. Without a name your file is just a set of bytes, you cannot tell if this a DOC or PDF or JPG file.

Sergey Kornilov admin 8/11/2016

You can start by posting the exact error message. Do not omit anything, post it exactly the way it is.

P
PHPRunnerExplorer author 8/11/2016

<<< Record was NOT edited >>>
8152 [Microsoft][SQL Server Native Client 11.0][SQL Server]String or binary data would be truncated.

3621 [Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated.



You can start by posting the exact error message. Do not omit anything, post it exactly the way it is.

Sergey Kornilov admin 8/11/2016

Does it also show PHP stack trace?
The error message itself is pretty clear, just need to figure out which field causes that. Normally full error message contains the SQL query itself. If this is not the case you need to enable SQL debugging to find the exact SQL query:

http://xlinesoft.com/phprunner/docs/debugging_tips.htm
Another option is to use SQL Server profiler to find the exact SQL query that causes the trouble.
Another note - it is really strange that it works under local web server and doesn't work with your server. This kind of error is database specific and should appear if you use the same database in both cases. There must be something else involved.

P
PHPRunnerExplorer author 8/11/2016

It's the thumbnail field. If we remove the Photo_Id (This is the image field we're testing), but leave the Photo_Id_Thumbnail field to update, then the error occurs.
If we leave the Photo_Id in, but remove the Photo_Id_Thumbnail field, then the truncate error occurs.
So do we need to set the Photo_Id_Thumbnail field as varbinary, same as the Photo_Id? I'll look to see if there are some medium fields in Sql Server, similar to MediumBlob.
Anyway, I think we'll be able to resolve this, thanks. If you have a chance, can you have a look at the Keep/Delete/Update question? These fields keep showing up, cluttering the screen. I think that's the only remaining problem, right now.



Does it also show PHP stack trace?
The error message itself is pretty clear, just need to figure out which field causes that. Normally full error message contains the SQL query itself. If this is not the case you need to enable SQL debugging to find the exact SQL query:

http://xlinesoft.com/phprunner/docs/debugging_tips.htm
Another option is to use SQL Server profiler to find the exact SQL query that causes the trouble.
Another note - it is really strange that it works under local web server and doesn't work with your server. This kind of error is database specific and should appear if you use the same database in both cases. There must be something else involved.

P
PHPRunnerExplorer author 8/12/2016

Follow-up - All of the List/View/Edit/Add screens look good now.
There's the still the problem of deployment, because running it on the server won't display the images. We can add images from the server application, and the changes show up in the database, and can be displayed by running from PHPRunner's internal server.
We'll search around the web for similar symptoms, look at the Source Page and permissions. If we can't resolve this in a day or two, we'll open a separate thread.
Thanks admin, have a good weekend.



Thanks admin,
"database file' - this is your file that is stored in the database, in field like VARBINARY."
You mean, the binary image file, extracted from the contents of the actual jpg? Ok.
""Name of a 'database file' - is the name of your file. You need to select a text field that belongs to the same table to store the name of the file. Without a name your file is just a set of bytes, you cannot tell if this a DOC or PDF or JPG file."
Yep, I have that text field.
Before you responded, we went ahead and implemented Thumbnails for one of the images, after throwing in a Binary field in Sql Server, for the thumbnail. Also, we shifted everything to PHPRunner 9.
It almost works perfectly, except for the (Keep/Delete/Update) radio buttons. How do we get rid of those, and get the program to understand that the image in the varbinary field, is valid?
Hmmm. I'm getting a Sql Error, when we run it on the server, Choose a file and then Save, that a String or binary data would be truncated. This doesn't happen when running it with PHPRunner's internal server. It's the same database - varchar(50) for the filename, varbinary for the image, binary for the thumbnail.
Yikes. Also, when we View the list of existing records from the PHPRunner internal server, it shows the thumbnails for that field. When we run it from the server, they don't show up; the fields are just blank.