Magnus Posted July 11, 2011 Share Posted July 11, 2011 Hi, I have just started reading part 3 of the book and downloaded the code; but I have trouble with the absolute referenced links. I am using WAMPSERVER on Windows XP, PHP 5.2.11, Apache 2.2.11, and MySQL 5.1.36. I did not have any problem with the first site, or with any other site... but this is the first time for me with absolute references. If I do as Larry says on page 185 that one should not do, adding a dot before the slash or stripping the first slash, it works. But I understand that this will cause problems with the mod rewrite later... Has anyone run into the same problem, and managed to solve it? Thanks! Magnus Link to comment Share on other sites More sharing options...
Larry Posted July 11, 2011 Share Posted July 11, 2011 Where are you placing your site files and what URL are you using? Link to comment Share on other sites More sharing options...
Magnus Posted July 12, 2011 Author Share Posted July 12, 2011 Where are you placing your site files and what URL are you using? Hi Larry, This is the second of your books I am reading; the reason why I did not register in the Forum before is that this is the first time I have run into problems :-) I learned PHP from your book PHP and My SQL for Dynamic Web Sites, 2nd edition. I definitely will buy the new edition as soon as it comes out to update my knowledge. Thanks for translating Geek into English! I placed the files in C:wamp/www/ecom2/html Here is how I tried to define the paths in the config file: define ('BASE_URI', 'C:\wamp\www\ecom2\\'); define ('BASE_URL', 'localhost\ecom2\html\\'); define ('MYSQL', BASE_URI . 'mysql.inc.php'); I think the BASE_URI is ok, because the database is connected, but looses contact if I change the BASE_URI. I have tried various different solutions for the BASE_URL, without success... And here is the URL I am using: http://localhost/ecom2/html/ Example from the header: This is not working: <link href="/css/style.css" rel="stylesheet" type="text/css" /> This is working: <link href="./css/style.css" rel="stylesheet" type="text/css" /> This is working: <link href="css/style.css" rel="stylesheet" type="text/css" /> Thanks! Magnus Link to comment Share on other sites More sharing options...
Larry Posted July 13, 2011 Share Posted July 13, 2011 Thanks for the nice words. Your BASE_URI and BASE_URL values are fine (kudos). Your absolute references such as /css isn't working because the css directory isn't at the root of the Web site; it's at /ecom2/html/css. Because your site isn't at /, you'll need to change instances (in HTML and CSS) to initial / to /ecom2/html/ Also, your relative references, such as ./css and css/ will work for the index page, but won't when you get to the browse and shop pages, which act as if they're in subdirectories (because of mod_rewrite). Link to comment Share on other sites More sharing options...
Magnus Posted July 17, 2011 Author Share Posted July 17, 2011 Thanks for the nice words. Your BASE_URI and BASE_URL values are fine (kudos). Your absolute references such as /css isn't working because the css directory isn't at the root of the Web site; it's at /ecom2/html/css. Because your site isn't at /, you'll need to change instances (in HTML and CSS) to initial / to /ecom2/html/ Also, your relative references, such as ./css and css/ will work for the index page, but won't when you get to the browse and shop pages, which act as if they're in subdirectories (because of mod_rewrite). Now I have found the problem, and the solution... The problem was that I had not set up WAMP with virtual hosts. The solution was a good tutorial (http://cesaric.com/?p=255) on how to set up virtual hosts in WAMP; and now the site works :-) /Magnus Link to comment Share on other sites More sharing options...
Larry Posted July 18, 2011 Share Posted July 18, 2011 That would be an alternative solution, and was what I did when writing the book (or working on any new project). Link to comment Share on other sites More sharing options...
Recommended Posts