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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default image

Status
Not open for further replies.

jen0dorf

IS-IT--Management
Apr 15, 2008
104
GB
Hi

I've created a table which contains various fields ten of which are for images where I want to store the image name ie 1.jpg I've set the default in the table design to be noimage.jpg

However when I fill out the web form and post to create a new record if I leave the upload field for images blank then no default image is shown in the table when viewed in phpmyadmin.

Is my issue with my table design of the web page php uplaod sequence?

I listed the table below
thanks

Ian

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`UserID` int(11) NOT NULL auto_increment,
`UserEmail` varchar(500) default NULL,
`UserPassword` varchar(500) default NULL,
`UserFirstName` varchar(50) default NULL,
`UserLastName` varchar(50) default NULL,
`UserCity` varchar(90) default NULL,
`UserState` varchar(20) default NULL,
`UserZip` varchar(12) default NULL,
`UserContactHours` varchar(12) default NULL,
`UserEmailVerified` tinyint(1) default '0',
`UserRegistrationDate` timestamp NULL default CURRENT_TIMESTAMP,
`UserVerificationCode` varchar(20) default NULL,
`UserIP` varchar(50) default NULL,
`UserPhone` varchar(20) default NULL,
`UserFax` varchar(20) default NULL,
`UserCountry` varchar(20) default NULL,
`UserAddress` varchar(100) default NULL,
`UserAddress2` varchar(50) default NULL,
`UserSex` varchar(20) default NULL,
`UserEthnicity` varchar(20) default NULL,
`UserAge` varchar(20) default NULL,
`UserTypes` varchar(20) default NULL,
`UserArea` varchar(20) default NULL,
`UserImage1` varchar(20) default 'noimage.jpg',
`UserImage2` varchar(20) default 'noimage.jpg',
`UserImage3` varchar(20) default 'noimage.jpg',
`UserImage4` varchar(20) default 'noimage.jpg',
`UserImage5` varchar(20) default 'noimage.jpg',
`UserImage6` varchar(20) default 'noimage.jpg',
`UserImage7` varchar(20) default 'noimage.jpg',
`UserImage9` varchar(20) default 'noimage.jpg',
`UserImage8` varchar(20) default 'noimage.jpg',
`UserImage10` varchar(20) default 'noimage.jpg',
`UserEyeColour` varchar(20) default NULL,
`UserHairColour` varchar(20) default NULL,
`UserHips` varchar(20) default NULL,
`UserWaist` varchar(20) default NULL,
`UserBustChest` varchar(20) default NULL,
`UserHeight` varchar(20) default NULL,
`UserWeight` varchar(20) default NULL,
`UserHatSize` varchar(20) default NULL,
`UserDressSize` varchar(20) default NULL,
`UserSmoker` varchar(20) default NULL,
`UserDistinguishingFeatures` varchar(50) default NULL,
`UserShoeSize` varchar(20) default NULL,
`UserGloveSize` varchar(20) default NULL,
`UserModellingExperience` varchar(50) default NULL,
PRIMARY KEY (`UserID`)
) ENGINE=MyISAM AUTO_INCREMENT=127 DEFAULT CHARSET=latin1;

-- ----------------------------
 
Hi

Ian said:
I've set the default in the table design to be noimage.jpg
Personally I not like such practices. If in the future you decide to
[ul]
[li]use different default image based on UserSex containing a gender specific shadow, called noimagemale.jpg or noimagefemale.jpg[/li]
[li]use internationalized default images containing language specific text, like "no image" or "Kein Bild"[/li]
[/ul]
you will have to write the handling of default outside the database. So I would skip setting any default.

Using 10 fields also looks bad. If in the future you decide to
[ul]
[li]allow more than 10 images per user[/li]
[li]allow caption for each image[/li]
[li]allow categorization of the images[/li]
[li]allow setting view permissions for each image, like public or private[/li]
[/ul]
you will find it more difficult to implement the changes. I would keep the images in a separate table.
Ian said:
Is my issue with my table design of the web page php uplaod sequence?
I would say, the problem is in your un-posted [tt]insert[/tt] statement. If you explicitly insert [tt]null[/tt] or empty string ( '' ) into the database, the given value will be used. The default value will be used only if you skip the field in you [tt]insert[/tt] or if you explicitly specify [tt]default[/tt] as the value.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top