Jump to content
Larry Ullman's Book Forums

HartleySan

Members
  • Posts

    3047
  • Joined

  • Last visited

  • Days Won

    243

Everything posted by HartleySan

  1. Can't take credit for this idea, but I got a great suggestion from a friend: < I thought that was really clever. I think I'll go with that, unless someone has a better idea.
  2. Thanks for that info. Actually, this all isn't really that big of a deal. Just surprised that there's no easy way to handle this in HTML.
  3. I looked into the %0a/%0d issue rather extensively, and after researching the matter and testing various things, I think the following link explains the situation best: http://bytes.com/topic/php/answers/498761-replace-cr-lf-textarea-str_replace I particularly liked the response by Iván Sánchez Ortega and the link he provided. Hopefully that sheds some light on things. If you have any further questions, don't hesitate.
  4. Hmmm...okay. Thanks for the ideas. I wonder if I could enter an HTML comment in between an entity code or something. I scoured the Net, and could not find any definitive answer. I kept looking at the source code for sites using <, but it's not obvious. Well, I'll keep looking. And if nothing else, Antonio's idea works.
  5. Well, I'm not sure how your XML file is constructed, but I'm assuming that on each line of the file, there is a URL to a tweet, yeah? That being the case, once you parse out the URL from everything else, than you need to load each URL into a separate a tag. This could probably be accomplished from the foreach loop you already have written. Or you could write a separate loop outside of the function for going through each entry in the array, and grabbing the URL. The choice is yours.
  6. Well, the printing options work the same way as anything else. If the print options are unique to each item, I suppose you could keep the print option in the items table. Otherwise, make a separate table, and then link to it using foreign keys. That's kinda up to you, I think. I cannot understand your last question though. What do you mean by "Could I not just put the item in the database manually with the design linked to the item"?
  7. I have an HTML question. Wasn't sure where else to put it, so I'm posting it here. Anyway, this might sound like a silly question, but I want to be able to literally display HTML entities on an HTML page. For example, I want to be able display < on an HTML page instead of <. Does anyone know how to do this? Thank you.
  8. Use a tags and set the href attributes to the URLs to the tweets. For example: echo '<a href="' . $sURL . '">A tweet</a>'; Sorry if my explanation is lacking.
  9. That Collator library is quite interesting. Never heard of it, and it deals with some very advanced sorting. The Japanese hiragana check might prove useful for a site of mine in the future. Thanks.
  10. I'm glad I guessed the right answer. "The blind squirrel finds another acorn!"
  11. Again, Stuart makes some compelling points. Probably all the more reason to entrust the logic and validity checking to jQuery. If you wanna take the more do-it-yourself, manual approach, you can use regexes, but note that the regexes to properly parse a date are quite complex.
  12. I don't know the details of what you're thinking, but maybe something like the following: 1) Have a table for categories (i.e., business cards, flyers, posters, etc.). 2) Have another table for specific items, which would contain a foreign key that links to the IDs in the categories table. 3) Have a third table for designs. The designs table would have specific information about the various designs, and also contain a foreign key, linking the table to the IDs of the categories table. You would then need to use joins to combine data for queries. This is, of course, very similar to Larry's second example site in the book, so basing everything off of that and using stored procedures, etc. would probably be beneficial. Anyway, depending on a variety of things, you may need to adjust my overgeneralization, but I think that's a starting point. What do you think? Edit: And like Jonathon said, you'd have to assign the proper values to each of the check boxes by making the appropriate query on page load, and setting the appropriate IDs, etc. to the check boxes.
  13. You can also use DHTML to add meta tags on the fly. In other words, you can use JavaScript to dynamically add meta tags to the page. That, however, is a client-side solution, and is removed from PHP. The choice is yours.
  14. It is odd. I would guess that a DB connection is not properly being established, since all the errors are related to the $r variable, which is based off the DB connection and the query. Really not sure, but the issue might be in your included DB connection script.
  15. Not sure about the following: // Omit the closing PHP tag to avoid 'headers already sent' errors! ?> But in all seriousness, I would do a few things differently: 1) I would not put any HTML in the file directly. The opening and closing div tags should go in the header and footer respectively. 2) I think you need the if/else conditional to also serve up an errors.html page if the database query is not successful. 3) I think the logic for the login should be in the header.html file, although I have not admittedly thought this through thoroughly yet. 4) You could just use the PHP $_SERVER superglobal to get the part of the URL you want for the directory name, instead of setting it statically. (Optional) 5) I still think it's unnecessary to include the show_gallery script. Seems a lot easier to just put the code in the index files directly. If you design them properly, they'll never have to be edited anyway. Was gonna wait for Larry to post, but decided to just chime in anyway.
  16. If you don't want to use JS/jQuery, then dropdowns are definitely the easiest option. They're quite common, even on huge websites as well, so I'd definitely consider that.
  17. Good to know. Thanks a lot. Maybe Larry will add this info to the errata.
  18. Haha! This post made me laugh because I had the EXACT same issue. Thanks for summarizing it. I also ran into the issue of two php.ini files in my installation at the time. Definitely, always use the most up-to-date XAMPP. I usually just do a search from the xampp folder to quickly find the file. Once you're in the file, if you text editor supports searches, just search for "curl". There's only one. And yeah, the most important thing is to shutdown and restart the XAMPP Control Panel. I had the same problem as you. Thanks a lot for this post.
  19. I wasn't aware of that Stuart. Thanks. Certainly, full-text searches are a tricky beast. I try to avoid them altogether. I suppose another option would be to acquire all the necessary data from a query, and then use regexes to parse the returned results.
  20. Ah, okay. I am sorry for my misunderstanding. It's looking like you'll want to use the strtotime function then: http://php.net/manual/en/function.strtotime.php I found the following note in the link above to be particularly interesting: The above really stresses the fact that it's important to not use ambiguous dates. For example, you said 12/10/2011, but I don't even know if that's December 10 or October 12. The strtotime function seems really similar to the jQuery function recommended by Stuart above, but using strtotime will allow you to keep everything in PHP. Anyway, hope that helps.
  21. I would assume that a category would contain mulitple subcategories. That means that there is a one-to-many relationship between the category and subcategory tables. In which case, the category ID should be a foreign key in the subcategories table. For example: Category table id category_name 1 cars 2 trucks --- Subcategory table id category_id (foreign key) subcategory_name 1 2 Ford trucks 2 1 Ferrari sports cars 3 1 Honda coupes Anything, I think you get the point. Then, you could use joins to get the proper info and have a properly normalized DB.
  22. I cannot respond to your question about \r\n vs. %0d%0a at the moment. I'll try and play around with it when I get home tonight and find an answer. It might be something to do with your specific browser though. Are you using Safari on your Mac OS? I suspect that that has something to do with it. There are a couple other small things I noticed though: - If you're going to place a form in your script, you should include the other appropriate HTML tags (i.e., a doctype, html, head, body, etc.) in the file directly, or via header and footer include files. - Your ternary operation syntax does not seem valid (but I'm not 100% sure). I think the closing parenthesis before the semicolon should go right after get_magic_quotes_gpc() to make the following: $before = (get_magic_quotes_gpc()) ? stripslashes($_POST['example']) : $_POST['example']; - You said that you're using the array_map function on the entire POST array, but nowhere in your script are you using the array_map function or using the entire POST array as an argument. - In regards to str_replace, why are %0a and %0d (that ones without double quotation marks) replaced with " (double quotation marks)? According to your str_replace call, they should be replaced with a space (i.e., ' ') and nothing more. I look forward to a response. Thank you.
×
×
  • Create New...