Forums

This topic is locked

SQL/file field - default value problem

Posted 21 Sep 2004 01:48:24
1
has voted
21 Sep 2004 01:48:24 shaun carter posted:
I am trying to set up a default value to list in a field on a SQL DB table, the default value is supposed to point to a .jpg that says 'no pic available', after many attempts of submitting my form with no pic file included I am lost,

The only thing that I can conclude is that the default value only loads if the Field value is NULL, the problem is that for some reason the field value is NOT NULL, it is blank, I can only assume that a space or something is being loaded from the form. I have wasted hours on this and I am begging for a solution, I am using pure asp upload 2.17, the code for the file box is listed below,

<td class="bodytext" valign="top">Insert a photo here

(300KB Max)
<input name="file" type="file" tabindex=17 onChange="checkOneFileUpload(this,'GIF,JPG,JPEG',false,300,'','','','','','')" size="20">

</td>

I have 2 questions/requests: -
1) there is an Alt (alterative text) box on the properties of the image place holder,... Is there any way that I can direct that to the image that I want?
2) Is there a way to make the SQL default value work?

I would be very, very grateful of a solution,

best regards
ShaunC.., Xtreme Newbie,
(office hours)
(after office hours)

Replies

Replied 21 Sep 2004 13:54:02
21 Sep 2004 13:54:02 Kent Steelman replied:
Are you putting the file in the database or the path of the file?

Wm. Kent Steelman
Replied 21 Sep 2004 13:59:45
21 Sep 2004 13:59:45 shaun carter replied:
I am putting a path into the database field.
Replied 21 Sep 2004 17:15:32
21 Sep 2004 17:15:32 Kent Steelman replied:
Is this Microsoft SQL and if so you can set up the path as a default value in the table. The next question is how is the call in your code.. relative path or are you using the full path (www.yourname.com/path/) this will determine what your default path value in the table should be.

Wm. Kent Steelman
Replied 21 Sep 2004 17:37:38
21 Sep 2004 17:37:38 shaun carter replied:
Kent thanks for the reply.. but this is what I have said at the top it is SQL server and the default value isn't working, I think this is because an entry must be being made to the field, I conclude this because the field is not listed as NULL, the path would work I agree if the default value loaded, the question was can I make a Javascript 'alt' tag display a picture?
Thanks
Shaun
Replied 21 Sep 2004 19:00:33
21 Sep 2004 19:00:33 Kent Steelman replied:
I am doing this with access and not having any problems at all... what is in your database field after the write/update is made?

Wm. Kent Steelman
Replied 21 Sep 2004 21:16:25
21 Sep 2004 21:16:25 shaun carter replied:
Kent,

there is nothing in the field... more importantly not a NULL therefore an empty string must be being put in the field, that's the problem, I can't find the empty string though, as I am new to this... <img src=../images/dmxzone/forum/icon_smile_shock.gif border=0 align=middle>(

I have uploaded the complete code to www.motoringsw.com/temp.htm
I would appreciate an expert eye cast over this.. best regards
Shaun
Replied 06 Mar 2008 20:43:55
06 Mar 2008 20:43:55 Ana Rodrigues replied:
I have the same problem, can you help me to understand?

thanks
Replied 07 Mar 2008 15:05:11
07 Mar 2008 15:05:11 Alan C replied:
hello guys,

I have something like this, and tackle it by storing only the filename in the table, and having a default set up so that if there is no image the database automatically contains something like awaiting_image.jpg and have an image called that in my folder, the image just has text that says what you would expect - 'awaiting image'

then in my display script

<pre id=code><font face=courier size=2 id=code> &lt;?php echo IMAGE_PATH_THUMBS.$row_rsPropertyUpdate['p_image_path'] ?&gt;</font id=code></pre id=code>

IMAGE_PATH_THUMBS

is defined in an include file as

<pre id=code><font face=courier size=2 id=code> define("IMAGE_PATH_THUMBS",'/property_images/thumbs/');
</font id=code></pre id=code>

so it's a path relative to the site root

and 'p_image_path' is the field name in the table

that works fine, until the images are uploaded visitors see the placeholder images that say awaiting image

hope it helps to see it

Reply to this topic