Define Constants For Site (Chpt 3, Pg 58)
Posted 28 January 2012 - 12:28 PM
The second and third constants are set up:
define ('BASE_URL','www.example.com/'); line 8
define ('MYSQL', BASE_URL . 'includes/mysql.inc.php');
Is this defining the URL of the website and do I also need to change this URL in my php.ini file? This part doesn't make sense to me since I am using http://localhost/
These are my errors:
An error occurred in script 'C:\xampp\htdocs\index.php' on line 8:
require(www.example.com/includes/mysql.inc.php) [function.require]: failed to open stream: No such file or directory
Fatal error: require() [function.require]: Failed opening required 'www.example.com/includes/mysql.inc.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\index.php on line 8
In my php.ini file under paths and directories, it has:
; Windows: "\path1;\path2"
include_path = ".;C:\xampp\php\PEAR"
Does this need to be changed to www.example.com or do I change my constants to this path?
Posted 28 January 2012 - 2:12 PM
define ('BASE_URL', '/')
I have my site setup like this
define ('BASE_URI', 'http://localhost/knowledge_is_power/'); define ('BASE_URL', '/www/'); define ('PDFS_DIR', BASE_URI . '/pdfs/'); // Added in Chapter 5. define ('MYSQL', '/includes/mysql.inc.php');
I am also using the xampp localhost for running the knowledge is power website, the location of my index.php file is here
And on the c drive it is located at
This should be enough info for you to figure it out if the above what i have written doesn't happen to work.
Posted 28 January 2012 - 2:24 PM
Posted 1 February 2012 - 11:57 AM
define ('BASE_URI', 'C:\xampp\htdocs\'); define ('BASE_URL', 'http://localhost/');
Posted 29 July 2013 - 2:13 AM
Thanks again, Edward! I've just spent a few million seconds rereading your comments, rechecking my stuff, slightly simplifying my file names, comparing, testing, scratching, etc., and finally have success with the KIP site. What worked in the config.inc.php file is this:
Posted 29 July 2013 - 6:24 AM
Glad you managed to get it worked out. The cute boxes with colored text is a code box, you can add one to your post by clicking on the "<>" icon just below the smiley face icon.
Yes you will need to get some data into the database as some errors may be thrown if its trying to fetch something that is not there, that's unless you check for null values etc.
Posted 29 July 2013 - 7:36 AM
Geoffrey, thanks for commenting.
I think the key to getting everything to work is to realize that your BASE_URL constant should be accessible from any web browser by starting the URL with http or https.
On the other hand, the BASE_URI constant should be defined as per the directory path to your server files on the actual web server.
In the case of a localhost on a Windows systems, this is likely akin to starting the path with "C:\", whereas on a Unix/Mac system, starting the path with "/".
Posted 29 July 2013 - 3:04 PM
Thx again, Edward, and HartleySan!
I was premature in thinking the Coffee site would emerge in its full glory! After setting up the db (carefully, after reading Larry's instructions after first trying without), the site "works" in that it comes up in browsers without error messages, but it's not displaying everything correctly. Here's what it looks like:
[NOTE: When trying to post this, later, I got a message, "trying to post more images than allowed" - so I've replaced some or all with text describing them.]
We're so glad you made it. Have a seat. Let me get you a fresh, hot cup o' Joe. Cream and sugar? There you go.
Please use the links at the top to browse through our catalog. If you've been here before, you can find things you bookmarked by clicking on your Wish List and Cart links.
Clever Coffee, Inc. has been selling coffee online since 1923. For years, Clever Coffee, Inc. failed to make a profit, due to the lack of computers and the Internet. Yadda, yadda, yadda.
It's safe to shop here, promise!
define ('BASE_URI', 'C:/xampp/htdocs/_LUecommerce2/'); define ('BASE_URL', 'localhost/_LUecommerce2/html/'); define ('MYSQL', BASE_URI . 'mysql.inc.php');
Posted 29 July 2013 - 3:22 PM
It probably doesn't matter, but in Windows systems, you should use backslashes instead of forward slashes for paths. In other words, I'd change your BASE_URI string to the following:
Note that a second backslash is required in each instance to escape the first.
Beyond that, it's hard to help, as I can't honestly make sense of your post or what the problem is.
Would it be possible to put your site up on a public-facing server for us to see?
Posted 29 July 2013 - 10:05 PM
Actually, you can use a single forward slash on Windows (which is unusual, but works), you just can't use a single back slash (which is normal, but doesn't work).
The problem is that your site is in a subfolder: localhost/_LUecommerce2/html/, not just localhost. You've should have absolute references to the images, links, and CSS (which is required with the mod_rewrite), but your references probably don't start with /_LUecommerce2/html/.
Posted 30 July 2013 - 12:46 AM
I understand that Windows allows either way, and indeed your suggestion made no difference, but thanks. I had mentioned that that configuration worked fine for me with Larry Ullman's ecommerce1 site (Knowledge is Power). Looking at your second point, I think that must be the explanation, and I'll dig into it. Thanks!
Re. what it's all about: I'm simply trying to get Larry's e-commerce (per his Effortless E-Commerce book) working under xampp on my PC so that I can get to learn from them. I have the Knowledge is Power site working fine, but t would be nice to have the Coffee site working as well, since it contains functions I need to acquire skills in.
My desire to learn this stuff is to use it on a website that I already have working (aquasilver.ca) but lacking e-commerce capabilities such as a decent, flexible shopping cart and Authorize.net e-payments (plus member log-in and possible also PayPal eventually). I had PayPal working OK but found its shopping cart totally inadequate for my needs, then eventually discovered Larry's book, etc. and figured it would be my fastest route to doing what's needed (plus helping me get smart enough to do some other web projects I want to pursue).
I'm currently wrestling with the BIG question whether to (A) keep my existing aquasilver.ca site structure more or less as it is and somehow add Larry's techniques into it, or ('B') start fresh with a total copy of Larry's Coffee site in place of aquasilver.ca then somehow slide my aquasilver stuff into it, replacing the Coffee look and feel where applicable. My existing site structure is VERY different from Larry's Coffee site so my head is spinning over this question.
My intuition tells me that the "B" option would be best, though I have nothing concrete to back that idea up!
Since I'm accustomed to working with Dreamweaver, I would be doing one or the other of these two options within an aquasilverTEST folder in c:/xampp/htdocs (as well as in my "local" folders on my D: drive, of course), side by side with my existing regular aquasilver folder in the same places. I use NotePad++ also, as appropriate and convenient.
Any assistance towards resolving this question would be extremely welcome, since both these options look rather intimidating to me at the mo! I'm sure there must be a wisdom-based choice better than what would happen if I tossed a coin to resolve it or just went on my intuition.
Posted 30 July 2013 - 11:11 AM
Wow! Geez! Those are some tough questions.
I guess it really comes down to your motivation and time available.
If you have both, then I say go with B. I'd rethink the entire site, and implement something more chic and modern looking that better emphasizes good UX.
If you have neither, then I'd maybe just change the Orders page to be able to accept online orders as per the guidance offered in Larry's book.
It sounds to me like you're already leaning towards B, but you're hesitant to do so because it's a big undertaking with a lot of unknowns.
If I could offer maybe two pieces of advice:
1) I'd stop using Dreamweaver ASAP. The sooner you wean yourself off of that and use a regular text editor/IDE designed for programming, the better.
2) If all your customers are in America/Canada, you might want to consider Stripe for your payment method.
Please share your thoughts.
Posted 31 July 2013 - 12:31 AM
HartleySan & Larry - with especial apologies to Larry!
I think I jumbled your separate replies, attributing them both to HartleySan. Guess I shouldn't work so late!
Re. Larry's point: "The problem is that your site is in a subfolder: localhost/_LUecommerce2/html/, not just localhost. You've should have absolute references to the images, links, and CSS (which is required with the mod_rewrite), but your references probably don't start with /_LUecommerce2/html/." If I understand that correctly, it means that I have either to put only my (aquasilver.ca) site files into xampp/htdocs/, hence being unable to use xampp for anything else, or to figure out how to fully qualify all the other stuff that needs qualifying, which I think is beyond me at this point. I guess I could move the ecommerce sites elsewhere on my system to study, in conjunction with using the ecommerce websites at dmcinsights.com to see how the code actually works in practice. That would be quite a workable solution but leaves me having to use xampp for only one test site (e.g. aquasilver.ca) at a time (acceptable I guess but not desired). Did I get this right?
Re. Dreamweaver, I think I'm already weaning off it. NotePad++ seems to work well, or would you suggest something else?
Re. aquasilver.ca, I agree it's not chic or modern. I had trouble communicating with my wife who came up with the graphic parts!
Re. my choice of how to proceed with getting Larry's code working on it, I'll continue pondering the options a bit.
Re: using Stripe for the payment method, I actually got quite enthusiastic about it a few weeks ago and so I was excited to hear that you (Larry) are getting involved there. Will you be coming up with tips on how to use it instead of PayPal and Authorize.net in your ecommerce sites?
Thanks again, and I greatly appreciate your kindness in helping people like me!
Posted 31 July 2013 - 1:07 AM
You can definitely have as many sites as you want running from the htdocs folder by putting each site within its own folder. So long as all the paths match up, you're fine.
I would not recommend deleting everything else in the htdocs folder just to get one site running from the folder.
Notepad++ seems to be good for a lot of people, but my personal preference is Notepad2. It's a bit simpler than Notepad++, but it has everything I need and more.
Anyway, yeah, I agree that it would be a good idea to make sure you can get all the site functionality working before you switch everything over. As you suggested, I would test all the purchasing logic, and once you're sure that's working, I'd redesign the site as well as maybe move the existing info around to make it more accessible, and when all that's done and running on your local server, then I'd move everything over.
Best of luck.
As a final note, I don't want to put words in Larry's mouth, but I'm willing to bet that the 2nd edition of the e-commerce book will contain info about Stripe. I'm hoping that he adds a third sample site to the book that uses Stripe as the payment method.
Posted 31 July 2013 - 9:05 AM
Yes, the second edition of the book will demonstrate Stripe, although it won't have a third example site. Rather than introduce a third example, I thought it'd be better to introduce a slew of ways that one can improve the first two examples.
Posted 31 July 2013 - 11:41 AM
I may get the 2nd edition, even though I already have the 1st edition as well.