Jump to content

plastik77

Members
  • Posts

    52
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

plastik77's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I am trying to force PDF files to download when the user's browser is IE, but display in the browser for all other cases. I have the PDF download part working, but not sure how to combine this with the browser check. Any ideas? Thanks This is what I have currently but obviously doesn't combine the conditions SetEnvIfNoCase User-Agent (Opera|Chrome|Version|Firefox|MSIE)[\/|\s](\d+)\. browser=$1 version=$2 SetEnvIf browser MSIE browser=IE SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf Header add Content-Disposition "attachment" env=requested_pdf
  2. Hi Keith, many thanks for your help - that nailed it. And I've changed the query to compare in unix timestamp format as you suggested!
  3. Hi - ah, the problem is that the subquery to select max number has the date comparison as a clause, but in fact I need to extract the max number first, then do the date comparison on that record - if that makes sense! The date comparison must have to be moved out of that subquery, does that mean an extra join?
  4. The query does return a set of rows, but the date check is not being done with the max data entry number - I know there are a few pets with data_entries numbered 1, 2 and 3 - these shouldn't appear in the result set as data entry number 3 is within the time period being checked, but because the comparison is done against the date of data entry number 1, these are showing up in the results. Hope that makes sense - and thanks for your help so far!
  5. Hi Keith, thanks for the reply, almost there I think. but I can't quite work out how to integrate this extra clause below with the date comparison. As soon as I add in the date comparison clause, the results no longer contain the mx data entry number - any ideas? SELECT p.id, o.id, o.email, d.MaxPetNumber FROM pets AS p INNER JOIN owners o ON p.owner_id = o.id INNER JOIN (SELECT pet_id, MAX(number) AS MaxPetNumber FROM data_entries AS d WHERE FROM_UNIXTIME(d.updated, '%Y-%m-%d') <= DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 25 day), '%Y-%m-%d') GROUP BY pet_id) d ON p.id = d.pet_id
  6. Hi, I am trying to pull multiple columns from 3 joined tables, but I want the result set to contain only one distinct "data entry" per p.id (the pet id which is a foreign key in the data entry table). The issue i have is that there could be two data entries, numbered 1 and 2, belonging to a pet - the query has to just pick the data entry with the highest number - that's why i was trying to use max and group by but it doesn't quite work. Can anyone see where i'm going wrong? Many thanks! SELECT `p`.`id`, `o`.`id`, `o`.`email`, MAX(d.number), `d`.`number` FROM (`pets` AS `p`, `owners` AS `o`, `data_entries` AS `d`) WHERE `p`.`owner_id` = `o`.`id` AND `p`.`id` = `d`.`pet_id` GROUP BY `p`.`id` ORDER BY `d`.`number` DESC
  7. Thanks for all the replies guys. I think I might start with svn then maybe move on to Git further down the line. Actually, the more I think about it, I might be better setting up the svn server directly on the web server, as the office server isn't going to be used for testing or anything, it will really just be a back up repository for files. I have root access to the web server (linux VPS), so i could install and set up SVN, then checkout files to my own machine whenever I need to do development work, before committing changes back to the web server. The office server could potentially just be updated periodically (via svn update), just to ensure the files are up to date. Do you think this makes more sense?
  8. Neil, I suppose I didn't really think of doing all my testing on the remote web server. I'm used to testing things locally then uploading it. I think I still need to get my head round how version control works and the (automated if possible) synchronisation of files between local and remote servers - maybe that's something that's handled differently depending on which CVS I go with, whether it be Git or SVN or whatever.
  9. I've had to work locally on my machine as the Mac server only has PHP4 and MySQL4 available, so all my local development work is run via a LAMP setup on my own machine. I've now convinced my work to upgrade the Mac server to Leopard, which means I can start using it for all my development work. That's why I am now in a position to try and get a good development/testing environment set up with version control
  10. Thanks for the reply Premiso. Yeah, I've used TortoiseSVN before on Windows and it was fairly straightforward, although I only used it for local development on my PC - this time I want to be able to work on the Mac server and link it up to my web server, so i'm a little bit unsure of the best way to go about this.
  11. Hi, I'm looking for some guidance on version control. I'm a solo developer and although I work with a couple of designers, I'm the only one writing and modifying code. I need to get a version control system up and running and I want to integrate it with my office server (Mac OS X server), so working locally would mean working (developing on a Ubuntu machine) with files on the office server, and commits to the web server would involve the office server pushing the files to the web server (via FTP or SSH etc). Can anyone give me some advice on the above set up and which software would might be best suited (i'm leaning towards Git at the moment)?
  12. @fenway - sorry about that. The relationships had been set up correctly, however, the problem was that in the pages table, I had visual_id set up as NOT NULL, default 0. This meant that when I was trying to insert new data into my pages table, i was getting the FK constraint error because it was looking for a corresponding record in the visuals table with id = 0. This record obviously doesn't exist (and never would as it as auto incrementing field), therefore the solution was to set visual_id to NULL.
  13. Hi there, I'm setting up my database structure for a project I'm just about to start. Having previously used MyISAM, I've decided to use InnoDB for this project due to the advantages offered with true foreign keys. However, I don't think I've set up my tables correctly as I'm not allowed to create any data. For example, `pages` is a table which may (but does not necessarily need to) have a visual attached to it, therefore there is a column visual_id in the `pages` table, which checks the `visuals` table. When I try and create some records within pages, I get the following error: Cannot add or update a child row: a foreign key constraint fails (`alona_hotel/pages`, CONSTRAINT `pages_ibfk_3` FOREIGN KEY (`visual_id`) REFERENCES `visuals` (`id`) ON DELETE NO ACTION) The error message above is telling me that I cannot add the row to the pages table because the value I've supplied for the visual_id column is not one of the values in the id column of the visuals table. The problem i have here i think is that a page isn't dependent on the visuals table, it may or may not have a visual associated with it. In this type of situation, should the foreign key constraint be removed altogether? Or is my design perhaps flawed? They way I have set up both the pages and visuals table is as follows. For situations where a cascaded delete is not necessary, I have set up the foreign key relation and added ON DELETE NO ACTION. -- Table structure for table `pages` -- CREATE TABLE `pages` ( `id` int(11) NOT NULL auto_increment, `name` varchar(250) NOT NULL, `url` varchar(250) NOT NULL, `date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `creator` int(11) NOT NULL default '0', `page_id` int(11) NOT NULL default '0', `visual_id` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `visual_id` (`visual_id`), KEY `page_id` (`page_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- -- -- Table structure for table `visuals` -- CREATE TABLE `visuals` ( `id` int(11) NOT NULL auto_increment, `url` varchar(250) NOT NULL, `alt_text` varchar(500) NOT NULL, `visual_type_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `visual_type_id` (`visual_type_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -- Constraints for dumped tables -- -- -- Constraints for table `pages` -- ALTER TABLE `pages` ADD CONSTRAINT `pages_ibfk_2` FOREIGN KEY (`page_id`) REFERENCES `pages` (`id`) ON DELETE NO ACTION, ADD CONSTRAINT `pages_ibfk_3` FOREIGN KEY (`visual_id`) REFERENCES `visuals` (`id`) ON DELETE NO ACTION; -- -- Constraints for table `visuals` -- ALTER TABLE `visuals` ADD CONSTRAINT `visuals_ibfk_1` FOREIGN KEY (`visual_type_id`) REFERENCES `visual_types` (`id`) ON DELETE NO ACTION;
  14. Thanks Michl. Good idea about the date picker, definitely more user friendly. I was a bit unfamiliar with date handling when i was working on this CMS, so that's why the approach is pretty clumsy. I'll have a look at php's date functions and get rid of varchar news.story_date. Appreciate the feedback!
  15. Thanks for the quick reply Mchl! Firstly, using TINYINT for boolean values makes much more sense. I'll update this. Regarding using ENUM for visuals.type, you're right this is a much better, more flexible approach. I wasn't very familiar with ENUM but having just checked out how it works, this is perfect for this instance. I use sha1 to hash passwords, so they will always be 32 characters long. Is VARCHAR appropriate for this? News.story_date is VARCHAR as I am allowing the user to enter a date manually. If there is a backlog of news stories, then they will not want all the stories to have the same timestamped date. So they enter a date in a certain format, the system validates it and then enters it in the db. I also convert the user entered date to UNIX format (converted_date), which made it easier for me to sort when retrieving news items and displaying in date order. This might be a pretty clumsy way to do it though, the more i think about it. The date_posted field is just the timestamp of when the story was actually created, for auditing purposes. Interested to hear if I could improve this section. Re user_tokens.user_agent, I will increase this to allow a bit more flexibility.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.