Jump to content
Larry Ullman's Book Forums

Jonathon

Members
  • Posts

    1064
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Jonathon

  1. Neither do I, but the manual is always a good place to look $_SERVER['PHP_SELF']
  2. Dynamically add the activated class to the link. You can achieve this using the $_SERVER array to find the current page and then depending on the page, load the link with the appropriate CSS class.
  3. If you want to you can post your directory/file structure and we can try and figure this out. Not everyone uses XAMPP but i think many are familiar with it, I use it and I'm pretty sure HartleySan does too. However, you're in no means obligated to.
  4. include("./file.php"); is the same as include("file.php"); It means to work from the current directory. ../ is to go up one directory level as you rightly point out. I only assumed that I had to put './' in front of a particular include the other day because I was including a file from within an included file that was in another sub directory. However that is merely just an educated guess...
  5. Thanks Larry, Yeah i'm not doing that for include + require (I nearly had a major melt down, when I thought I was) Hope you're well
  6. Hi Tony and Larry, Apologies I must be more clear, I have this horrible habit of rambling and not realizing that nobody bar me know what i'm actually on about I have used the BASE_URL for links and images, css links in this kind of way. a href="<?php echo BASE_URL; ?>a_page.php">A page</a> is that wrong? As for including files I just had a look over some recent work and I am not using absolute paths. Mainly because of the reason you said and I believe that the http wrapper is automatically disabled for XAMPP? So i didn't think it was possible But I have in my includes recently had to alter the path in some examples so that it had the "./" first (but i think that was because it was an include within an include) The main problem I had when i had a site that i tested on a live server was that i had to alter all the relative paths for CSS files, links, images, especially when using a mod re_rewrite that simulates a folder-esq structure like wordpress. Because they were just dynamic pages really. That's when i decided to use absolute where possible. My answer i suppose is more about the paths for links + images as opposed to includes. So apologies Tony.
  7. It does, I've got Windows 7 64bit, runs fine. Any problems let me know
  8. You can still fake it as far as i thought. Although I've never used WAMPP WAMPP test email
  9. I'm not sure as i don't use WAMP. But i imagine its the same as XAMPP. If you look in your php.ini file you should be able to set the send mail settings. Just google it i'm sure there are tons of people blogging it. Let me know how you get on
  10. Yeah Tony, I had the same problem. I had to go through and manually add ../ to everything. I thought it was because I was using a mod_rewrite to alter my url structure. Which i think in part it was, but often it was just XAMPP. I've actually just got a new system and XAMPP. I haven't however checked that xampp is calling files any differently to a liver server and it's my own fault, because I wrote in big fat letters on a list of things to do. "configure XAMPP to work seamlessly" - I shall at some point today try and check that. I normally just have a configuration file that has the settings for a live and local server so it knows what constants to use. However my work around has been to use an absolute path. it's simpler to use in my opinion actually easier to alter. I will try and find the answer to this for everyone using xampp
  11. I do not fully follow this part But I have had similar problems with xampp. It wouldn't include a file using: <?php include("includes/file.php"); ?> But it would if i used: <?php include("./includes/file.php"); ?> However I think that may of been because I was including a file within a file and it was in a sub directory. I had a look at the include path. It may be of some use to you. I'm not 100%. I've actually just changed my approah from totally relative paths to absolute as long as you keep a CONSTANT like DEFINE ('BASE_URL', 'http://www.example.com/'); then you can just echo this out in your pages + filename.php. Then if you want to use your files for the basis of a site just change the CONSTANT. I'm sorry I can't be more help. But no your not the only one, I had a similar problem and when I put the site up I had to change all the paths of images etc because the server wasn't liking how they were structured. Let me know how you get on
  12. I now have almost always moved to using absolute paths. I much prefer the look of relative, but when working with .htaccess in particular, it just really complicates the issue. I don't think i'd go back to relative now.
  13. Hello HartleySan, Thanks for your reply. I understand your view point and see that in reality you wouldn't store all info in a DB and 1 table is perfectly manageable. That's what I would do. However, this situation I made complex in order to create multiple instances of void data. Where you said: That isn't strictly true, there isn't one table per page, there would be 3 tables for the site, that in reality could have multiple pages. It is all down to preference, but using this extreme rule set I made, I felt that it allowed for a use of joins. But again it's all preference, had this of been a real site, then my content would have been more mixed between DB and hand code. But for me, there is still too much data that can be empty. You missed off the anchor text, link itself and also the alt tags. Again this comes down to personal interpretation as with so many web related things. But for me SEO is more than semantic code. For instance, the alt tags are the fourth thing a search engine scans on loading a page. So it was important that they are tagged properly and hence there inclusion in the DB. So when I tried to break down all the elements of a page i ended up with occasions where, `meta description`, `meta keyword`, `alt tag`, `link`, `anchor text`, `into_text` `img_path` could be empty. This for me just seemed wasteful i'd say nearly 40-50% at any one time could be empty. So by using a content_id for an individual content entry, that allowed for me to use it as a FK that allowed for 3 tables, no null fields. Thanks for your response though, I think we've probably taken this (some what unrealistic example) as far as possible . But i've appreciated your input. And more importantly, had a good play with joins
  14. Have you tried the MYSQL website? If this is your first programming book, it might serve you well to read Larry's PHP6 and MYSQL 5, which he is re-writing now and meant to be out the end of summer I think?
  15. A unique key is similar to a primary key. But you can have more than 1 unique key if you wanted to. You can only have 1 primary key often it is just a row_id that increments as items are added to the database. The unique index speeds up searching on that particular column to look for duplicates. You'll see examples of a unique keys being used in other works of Larry's such as 'username' or 'email' columns. Does that explain it for you?
  16. Thanks to HartleySan and Antonio for your replies. I shall look into Views for MYSQL. Yes I do agree with you HartleySan regarding camera sales. A similar table DB design to Larry's coffee site would be ideal. I enjoyed playing around with joins and spending some time to better understand them, so the main objectie has been achieved. But.. if I may, let me propose this scenario to you (or anybody who wants in), it's only fictitious, so there is no rush and no obligation, but I hope it gives you an insight to my thoughts on design: What table structure would you have for this scenario: 1 - All content must be in a DB 2 - There are 2 pages 3 - Index.php + person.php 4 - on index.php there are 3 divs. 5 - Each Div contains the following: a) <h1>A Person's Name</h1> <img src="path/to/image" alt="specific to person" /> c) <p>A small 300 character long introductory text (This must be unique and not just the first 300 characters from a larger set of text)</p> d) <a href="person/persons-name">related anchor text(Not just 'read more')</a> 6. we'll ignore person.php solely and concentrate on dynamic variations of person.php 7. So there can be person/person-a or person/person-b or person/person-c depending on what person the user wants to read about 8. The page must load: a) accurate titles for the page accurate meta description + keywords c) <h2>The person's name</h2> d) <p>A unique full length, several hundred words of content</p> e) And that's it Remember, all image alt tags, anchor text, meta description, meta keywords and page titles must be seo friendly and accurate. Also remember that this is a small example. But if it were a fully blown site there could lots of dynamic variation of pages and lots of content, alt tags, meta etc that would need to be accurate - Bearing in mind that on index.php there is no need for each piece of content to have it's own meta tags as the index page itself would have its own meta tags already about the site. But on person.php each piece of content does need appropriate matching meta tags. So straight away you would have a situation where, if you put all the information in 1 table, there would be some content that wouldn't require a `meta description`, `meta keyword` or `meta title`. So potentially 3 rows could be empty on certain rows. - Also, on person.php the content doesn't need to have a link or any subsequent alt tags or anchor text as the content doesn't go anywhere so there's nothing to link to. So if we have 1 table, there will be rows of content that would have an empty `anchor column`, empty `link column`, empty `alt_tags column`.
  17. I haven't got this book but is their a line above it, smething like foreach($var as $key => $value)(
  18. Empty is not the same as null. I think that you need to insert `fax_number` = null; Also I feel that I should mention that ideally you should try to avoid null fields in tables and perhaps use a join
  19. The curse of a coder in which no one is immune. The only thing is that once you make a mistake x number of times, you're normally a bit faster in correcting it.
  20. I understand the argument but how many sites can really warrant the use of databases that scale to that kind of level. Yes there are some, like Facebook etc. But most of the millions of websites online just wouldn't warrant that kind of need. However I do feel that NoSQL has become such a buzzword much like web 2.0 was. I have even seen a few adverts for websites to be built using the MongoDB etc.
  21. Hi Fergal! It should be <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  22. Yes in terms of articles and blogs you are correct. I neglected to mention those tables. The idea is fairly rough and I am still not 100% on some aspects of its design but we'll see. I shall try to explain, because I do feel I am having trouble getting it across :-( So I shall do it in bullet form(ish). - ALL content is stored in the database in this example (even though in some case it would be simpler just to code it in HTML. This was in order to make the concept complicated and unique. - You have a website. This website offers 3 services - photography - sales of cameras - Camera maintenance - On the index page there is a small introductory text that is unique to that page about each of the 3 services. This is not just the first x characters of the main content, this is to avoid a duplicate content issue. Each service's small introductory text has a link to to that service in full. - So photography's intro text will lead to services.php?service=photography or services/photography So from the index page we have a table that needs: - content_id (primary key) - content (introductory text on the service) - link (where does the introductory text take me to so I can read in more depth about this service) - anchor (I'm trying to imagine I was doing this properly and so I'd want strong internal links that contain good SEO structure, rather than omitting this table and just generically putting 'read more') - headline (So again I can place this between <h1> tags for search engines. i.e: <h1>photography</h2> <p>This is some intro text about photography<p/> <a>Great photographers</a> But this is not the table I have used!! I shall show you why I click on services/photography and the page needs to load: - headline ("Photography at a glance") - content (full content on the topic photography) - content_id (primary key) - There is no need for a link on this content or subsequently any anchor text because the content doesn't go anywhere and putting the same generic link 'back to somepage.php' would not conform to NF rules Therefore: I made two tables: Table 1 - content: - content_id - content - headline Table 2 - links: - content_id (foreign key, meaning the join pulls the content and links that go together) - link (self explanatory) - anchor (self explanatory) - link_id (primary key, not all content will need a link (hence two tables) so at some point there will be: - content_id = 5 - link = 'services/photography' - anchor = 'My favorite photographer' - link_id = 4 I threw in a meta-description table because as the services page relies on get variables it will need to alter dynamically the meta tags depending on the content being displayed. But not all content will need a meta tag, like the introductory text on the index page won't so putting these in the same table would result in empty rows. I hope this goes some way to explaining my reasoning. You may also notice that i had columns and a table called related to page_id. I'm not sure i need it, but when I was working this out some reason made me think that I did. I quite possibly don't. I'm sure i'll remember why at some point I put it in.
  23. You may find the bottom few threads of this topic answers your questions.
  24. Thanks for your replies. To elaborate on my schema. This example I wanted to pick a scenario that wasn't out of a book as it's too easy to just replicate tables, columns and queries and then think you've got it nailed. The content table houses all the content for the site. It could be for instance 4 separate pieces of information on the index page that outlines what you do. So the `headline` would be 'service one' and the `content` would be the opening paragraph lets say. The page_id for index is say 1 as it's the landing page, page_id for 'about.php' could be 2 and so on. The content_id is the primary key and used as a foreign key in other tables. The `links` are housed in a separate table because not all content will have a link. This happens because the content on many but not all pages is not in it's entirety. For example: the `headline` 'service 1' and `content` 'this is some intro text about service1' will have a link ('service.php?s=service1') to read more about this service. But the full main article will not need any 'further reading' or needs for links to go anywhere as it is in it's entirety. Hence why there is a separate links table. The meta table is again used to pull a more relevant set of meta tags information as a lot of the pages are dynamic and make use of get variables. I hope this clears up a little the schema.
×
×
  • Create New...