Jump to content

jggretton

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by jggretton

  1. So far, from what I can tell if it's a standard .css file it comes through fine, if it's a php driven one it occasionally goes wrong. I've actually founds another quirk which is that it seem to make a difference what html file (well, php file) I load the css document through. I'm not at my work station anymore, but I'll look into this further tomorrow, but it might be something to do with if the html file is still loading when it loads in the css... Not sure if that's right, but it's an idea. Thanks for your help, James
  2. Hi Ken, I hadn't posted code previously as there was a lot of framework stuff going on too, but after some experimentation I've managed to get the problem to occur with nothing but this code: /css.php <? header("Content-Type: text/css"); print "test"; ?> /.htaccess AddOutputFilterByType DEFLATE text/html text/plain application/json A few other points: So far, I've only noticed it in Google Chrome on the PC (XP & Windows 7) but this might be because the other browsers are more forgiving of fluff at the top of a css file It doesn't occur when accessing a file directly, only when it's loaded in by my HTML (so perhaps related to Connection: keep-alive?) When it does occur, the file comes down with no response headers. Chrome is then treating it as a application/octet-stream
  3. Well, I still don't know what's actually going wrong, but I've narrowed down the problem to DEFLATE compression in my .htaccess file. The problem is being caused by the following .htaccess rule: AddOutputFilterByType DEFLATE text/html If I remove this line then all works fine. Gzip isn't really essential for this site so I'm happy to leave it this way. Hopefully this will help anyone else with the same problem. If anyone does know what's really causing the problems here please do reply anyway - I'd be very interested to know. Many thanks, James
  4. Hmmm, has no-one experienced anything like this before then? I'm really stuck so would appreciate any ideas, however vague they might be! Many thanks
  5. Good call Ken, so gojo could fix this by adding the following line: $_FILES['image']['type'] = image_type_to_mime_type(exif_imagetype($saveto)); Just after the move_uploaded_file statement. So it would read: move_uploaded_file($_FILES['image']['tmp_name'], $saveto); $_FILES['image']['type'] = image_type_to_mime_type(exif_imagetype($saveto)); Hopefully that should do the trick!
  6. Most people do this using .htaccess and mod_rewrite. You can find some basic information on .htaccess files here, and more information on mod_rewrite here (see 'beautiful urls' section).
  7. The code below would do the trick: $string = "testing123"; $output = preg_replace('/./', '*', $string); print $output;
  8. If it's acting differently in IE and Chrome it's likely to be a problem with how the browser is displaying the images. Could you open the converted image directly in each browser and press refresh (ie go to http://www.yoursite.com/image-folder/converted-image.png) and confirm that they are really different?
  9. Hi all, I've got a frustrating problem on a site where PHP is outputting content *before* the headers, causing the headers to show up as plain text. This is only happening on a .css file which is powered by PHP (at least I'm only noticing it on a .css file) and is only happening occasionally, usually the second time I visit the site in a session, and not again for a while. Pressing refresh fixes it. I've listed some of the output below, lots of unknown chars, followed by the headers and then finally the actual stylesheet. Not that the first part may not have copy and pasted 100% accurately. If anyone has any ideas I'd be very grateful. Thanks, James ��#��P��(vԄ��l�?ml��ʇD�n.��r�����N d�F1eO�L4�� (Cc0��4�%s��h/�W�����zZ�y��%�`�����M“�c^^�I3s�8���#����]A���R��Hȗ��`G{� HTTP/1.1 200 OK Date: Mon, 28 Mar 2011 08:24:46 GMT Server: Apache/2.2.17 (Unix) FrontPage/5.0.2.2635 X-Powered-By: PHP/5.2.17 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Keep-Alive: timeout=5, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/css 24d8 @charset "utf-8"; /*---Stylesheet---*/ html, body{ ..........
  10. Thanks Mikosiko, they look very interesting - it's amazing how similar the first part of the dev.mysql.com article is to my question! The second article is a little over my head at the moment but I might spend a few hours learning about MySQL functions and then perhaps I will be able to use it in my project. Many thanks for your help, James
  11. Hi all, this may have been asked many a time but I haven't had any luck finding it. If you know of a past post that's similar please do point me to it. My problem is as follows: I've got a table of categories, with an `itemID`, a `parentID` and a `title`. The first level has a parentID of 0. Categories are then nested eg. the children of an item with itemID=1 have a parentID of 1. A categories can have multiple children, each child can have children etc etc. I'd like to achieve a MySQL statement which given the itemID of the bottom most child, will return all the items in the parent category, all the items in the parent's parent category, .... , until we reach the base. This may be unachievable so a more simple initial aim might be to get a statement which given the itemID of the bottom most child will return the parent item, the parent item's parent item, ... , until we reach the base. Below is an example table: CREATE TABLE `cats` ( `itemID` int(11) NOT NULL auto_increment, `parentID` int(11) default NULL, `title` varchar(128) collate utf8_unicode_ci default NULL, PRIMARY KEY (`itemID`)) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;insert into `cats`(`itemID`,`parentID`,`title`) values (1,0,'Foods'),(2,0,'Drinks'),(3,1,'Sweets'),(4,1,'Savory'),(5,3,'Biscuits'),(6,3,'Cakes'),(7,6,'Jaffa'),(8,6,'Sponge'),(9,5,'Hobnob'),(10,5,'Custard cream'),(11,5,'Abbey crunch'); So far I've can pull out the parent categories with a table for each: SELECT a.*FROM `cats` AS `a`, `cats` AS `b`, `cats` AS `c` WHERE c.itemID = 11 AND ( a.itemID = c.itemID OR a.itemID = c.parentID OR (a.itemID = b.parentID AND b.itemID = c.parentID) )GROUP BY a.itemID; But this wont work for n depths And I can also pull out pretty much everything by matching a.itemID = b.parentID SELECT a.*FROM `cats` AS `a`, `cats` AS `b`WHERE a.itemID = b.parentID OR b.itemID = a.parentIDGROUP BY a.itemID But this just gets me a mess of everything rather than the items I need. Does anyone have any suggestions for how I might go about this and also about the efficiency of the query? Thanks for any help you can provide. James
  12. Ah, thanks Mchl. That's certainly the stage I've now got to - make it UTF-8 and stop worrying about it! You have pointed out one bit which I previously missed (which is very important): Point 5. PHP - MySQL connection. I will have a play with this now. Thanks for your help, James
  13. Hello, in case anyone else comes across this question themselves, I did find a very useful article here: http://www.sitepoint.com/article/guide-web-character-encoding/ Backed up by a forum post here: http://www.sitepoint.com/forums/showthread.php?t=450442&page=1 (ignore the comments by the ranting bloke though) Any other good articles would be appreciated! Thanks, James
  14. Well if it's (b) you'll need to make some changes to the PHP code that submits the property to the database. When I submit data from checkboxes to a db, I usually clear all the db fields that store the checkbox first and then resubmit everything. How and what you'll need to clear will depend on your PHP code so I can't help you right off I'm afraid. You could try submitting the code to the forum, but if you're not experienced in PHP you will need to be very careful not to submit any sensitive data such as passwords within the code... You might be better off getting a professional to have a look?
  15. Hello Graham, is the problem that: a) checkboxes that are not visible on the page are still submitting data to the db or b) unselecting checkboxes does not unselect them in the db ? Just to warn you: either way, I think you'll probably end up having to edit the php...
  16. Sorry to bump up, but was hoping someone might have a suggestion? Thanks, James
  17. Hi all, I'm a reasonably experienced PHP developer however I keep on getting caught short by character encoding problems - e acutes in xml, pound signs from WYSIWYG editors, Mac characters Vs PC characters etc etc... I was hoping that someone might know of a good online guide (or book if necessary) which can teach me the basics and build up from there? I've spent a few hours doing Google searches but haven't found anything that clearly covers everything i need. Any recommendations would be greatly appreciated. Many thanks, James
  18. Interesting, I didn't know that this was possible with MySQL... I wonder how much processing this would take on a mySQL server? ie. if we had: UPDATE mytable SET `order`=`order`+1 WHERE `order` BETWEEN 2 AND 9999999 I might do a little performance testing and see! Thanks for your suggestion!
  19. Hi PFMaBiSmAd, thanks for the reply and sorry for my very slow response! The reason this problem has come up is because I have been focussing my efforts recently on creating some general reusable php classes for use in all my php projects. While making my SortData class (which theoretically could be used for any db with an order column) I was planning some of the public functions - moveUp(id), moveDown(id), swap(id1,id2) where easy, but positionAfter(id1,id2) posed the problem discussed. I completely hear what you say about usually only having a handful of data to re-sort when allowing manual resorting, but the problem still intrigued me and so even without a specific need I am still interested in finding a solution – or showing that there is no truly graceful solution! The cron / triggered when required solution certainly falls under the ungraceful category at the moment…
  20. Thanks for your reply Rarebit, unfortunately having the order the other way round wouldn't help me insert an item in a particular position in the list. I hear your comments about an occasional cron fix of the table though. This would make the floating point method more sustainable, but it still doesn't satisfy my quest for the nice clean solution! Any other thoughts anyone? Many thanks, James
  21. Hello, I currently have a mysql table structure similar to: id | name | order ------ ----------- --------- 1 cat 4 2 dog 3 3 fish 1 4 donkey 2 And when I output items I can use a query along the lines of: "SELECT `name` FROM `table` ORDER BY `order` ASC" which would return: fish donkey dog cat New items get a `order` value equal to their `id` and so appear at the end of the list by default. I've got a CMS which allows me to re-order the items by moving each up or down in the list. For instance, in the data above if I asked `dog` to move up, it would swap it's `order` attribute with donkey's. The table would then look like: id | name | order ------ ----------- --------- 1 cat 4 2 dog 2 3 fish 1 4 donkey 3 And my query would return: fish dog donkey cat This is fine for this amount data, but what if I had 1 million entries and I wanted to move 'dog' from position 1'000 to the top of the list (without reordering the other data), this would take 1000 individual swaps of the `order`s in the database. What if I wanted to insert a new item in position 500'000? Using the technique above I would have to update the `order` attribute of half a million database entries! Does anyone know of a better system for storing the order of items in a MySQL database? So far the only one I've found is using floating point numbers and setting the `order` = ( order above + order below ) / 2 but this does not sound very robust to me! Any thoughts / links would be greatly appreciated! Many thanks, James
  22. Hi all, I'm creating a website that lists snippits of online articles. As tagging these articles will be very important, I've created a database structure as below. I'm now implementing searching of these tags with the hope to sort potentially 1000's of matches by relevance on tags and on date (the newer the better). Before launching head first into this, can anyone point me in the way of a good tutorial specifically on tag searches. (I can find plenty of fulltext sytle search information, but not so much on tagging). Many thanks, James ------------- Table "article" id|text|...|creationDateTime|updateDateTime 1|"...."|...| 2006-......... | ...... 2|"...."|...| 2006-......... | ...... ------------- Table: "tags" id| tag |count 1| "car" | 0 2| "boat"| 2 3| "tree" | 1 -------------- Table: "article_tags" id|article|tag 1| 2 | 2 2| 2 | 3 3| 1 | 2 ...............
  23. That error message usually indicates that you haven't opened / closed your curly brackets somewhere. I count 11 { and only 10 }. This is the first problem you need to solve!
  24. Unfortunately not, a different page2.pdf is uploaded by the client each time so I currently only have this in PDF form. Thank you for your reply though!
×
×
  • 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.