Jump to content
Larry Ullman's Book Forums

tryingtolearn

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by tryingtolearn

  1. Hi all, trying to wrap my head around this (Its alot to digest!)

    Im on chap 9 and trying to alter things a bit.

    I want to create a way to display the author of the page. Like a credit type of thing (written by...)

     

    The Page class returns the creatorID but to get the user name associated with that ID to display is where Im not sure of the proper way to go.

     

    Ive read through the earlier chapters and it seems like either extending the class might work like in the pets example or the interface examples might work also.

    Then it almost seems to make more sense to simply do a join in the query.

     

    Im afraid of making things more complex than what they need to be because Im learning something new... if that makes sense

     

    So Im looking to the more knowledgeable for guidance on the best approach to get the user name associated with the ID in the Page class

     

    Any insight would be appreciated. Thanks

     

  2. Going off the assumption that you will be inputting the two different languages and not just translating the page text

    maybe something like this would work.

     

    1 database set up like this

     

    [table] lang

    -- id

    -- name

     

    [table] page

    -- id

     

    [table] page_lang

    -- id

    -- page_id

    -- language_id

    -- title

    -- content

     

    Then you have the user select their language and assign that ID to a session so it pulls the correct language title and content for the page.

     

    Seems like it would be the easiest to maintain and expand if you need to add another language.

    Just a thought.

    • Upvote 2
  3. Well they are not worth their salt as I got no love from them at all since they just kept saying that since the basic rules worked the server was configured properly.

     

    So - I started looking into why the $_GET var wasnt getting passed in the "Pretty URL" style.

    Turns out through much reading

    multiviews is enabled on the server so

    Apache is trying to find filename to map the path.

    Causing shop/ or browse/ to become shop.php or browse.php prior to reaching the rewrite rule therefore not getting the match, the rule isnt executed.

     

    So for the time being I added

    Options -MultiViews

    to the .htaccess file and presto - It is working now

    working ex.

     

    Thanks to both of you for sticking w/ the post - Its throwing ideas around that usually lead me in the right directions to explore the possibilities.

    I really appreciate this forum!!!

    Learned a bunch along the way.

     

    Now Im just keeping my fingers crossed that by adding the line to the .htaccess I dont create a different problem as I go from here.

    • Upvote 1
  4. All 4 vars are blank when I echo them out.

    So it still leads me to the rewrite rule not passing them.

    Changing

    RewriteRule ^browse/([A-Za-z\+\-]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3

    to

     

    RewriteRule ^browse/coffee/Dark+Roast/2$ browse.php?type=$1&category=$2&id=$3

    hasnt worked either which it should for just that particular llink anyway.

  5. Yes, The example I posted in post 4 works fine on both sites.

    I put a ticket in to the server support just to verify and they gave me a canned response that mod rewrite is enabled and that I would have to troubleshoot the code.

    and they cannot provide support for code yadayadayada

     

    Im reading up on the apache site all about re_write

    There has got to be something Im missing

     

    The dynamic links are fine but I really like the idea of it being SEO friendlier this way

    Plus - I really like learning the ins and outs

    Hell spent a ton of time with PHP and MySQL for Dynamic Web Sites(2nd Edition) and thats what got me into learning all this in the first place.

    So all in all its a positive!

    Great books!

  6. Thanks Terry,

    I have uploaded and reuploaded so many times trying to figure it out.

    No luck.

     

    Even on the site where the links go to a page and display it, it isnt displaying the correct items.

    The goodies page should be showing the flower mug and red dragon mug.

    Not the same coffee products as the coffee link.

  7. Both sites Running on Linux

    PHP ver 5.2.14

     

    Both are residing in the root directory now.

     

    First site that gives page cannot be displayed error

    My link

    Click Coffee Goodies Sales or any of the images

     

    Second Site

    My link

    Coffee Goodies Sales all bring up the same items but then click one of those items and you get an error page.

     

    Let me know if you need more info

  8. Thanks for the tip Jonathon

    Its just the code straight from the book(well download section for the book).

     

    <IfModule mod_rewrite.c>
    RewriteEngine on
    # For sales:
    RewriteRule ^shop/sales/?$ sales.php
    # For the primary categories:
    RewriteRule ^shop/([A-Za-z\+]+)/?$ shop.php?type=$1
    # For specific products:
    RewriteRule ^browse/([A-Za-z\+\-]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3
    # For HTTPS pages:
    RewriteCond %{HTTPS} off
    RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]
    </IfModule>

     

    Guess a better question would be - Is producing links in this manner a reliable method?

    It seems hit and miss since I get totally different results between two sites hosted at the same place w/ the same hosting plan.

     

    But using straight mod rewrite like

    RewriteRule ^/?testrw\.html$ testrw.php [L]

    works fine on both sites.

    you could go to testrw.html and get testrw.php instead.

     

    So just wondering now if anyone has got this working out of the box, and if so - wonder what the difference is.

     

    I think for reliability sake I need to just use the dynamic urls and take the hit on the SEO unless of course Im missing something somewhere.

  9. The problem gets even stranger,

     

    Im running the coffee ex on two sites

    Both hosted at the same place

    both have the same hosting plans

     

    The first test site I get page not found errors when clicking the coffee link

     

    The second test site

    I get the page /shop/coffee/ and see all the items

    Then if I click a view all link I get the error page so its telling me its not writing something???

     

    So am I spinning my wheels here trying to use the mod rewrite - Is it working for others?

    Should I just convert the links or does it sound like a different issue?

     

    Not understanding the differences between both sites on the same server?

  10. Hi all, Im working with the coffee shop ex.

     

    I cannot get the links to work that require the mod rewrite.

    (I have tested that mod rewrite is enabled and working by putting up a basic example on its own and it worked).

     

    I was trying to load all the files in a subdirectory, then a sub domain now I just have the files in the root and all I get in all tests is a page cannot be displayed error.

     

    I feel like Im missing something here but cant tell what it is.

    Is there something that needs to be changed from the download scripts - Im at a loss with this step.

    Thanks for any input.

×
×
  • Create New...