Solved

Why can't I get this web address to work?

Posted on 2014-12-22
3
119 Views
Last Modified: 2014-12-22
I've got a page that has this as part of it's code:

require_once ABSOLUTEPATH.'/includes/pdo.php';

When I run the page, I get the error that you see below. Basically, it's not seeing "pdo.php."

screenshot
ABSOLUTEPATH concerns me. The guy that designed this page sent this to me in an email:

In the php.ini file, we set the auto_prepend_file directive to point to /var/www/html/includes/includes.php (or wherever is appropriate for your environment.)

includes.php pulls in paths.php, which is where the ABSOLUTEPATH, ROOTURL, and IMAGEURL constants are defined. We recently simplified paths.php using __DIR__ instead of hard-coding a bunch of IP addresses. I’ve attached the latest copy.

I look in paths.php and it looks like this:

define('ABSOLUTEPATH', __DIR__.'/../');
//define('ABSOLUTEPATH', 'localhost/saw/');
define('ROOTURL', '/');
define('IMAGEURL', '/Images/newTemplate/');

I understand the purpose and advantage of "__DIR__ in that it establishes a base URL so you don't have to worry about relative URLs becoming a problem, correct? But the fact that when I go to "echo ABSOLUTEPATH" and all I get is "ABSOLUTEPATH," I'm thinking there's something wrong in that the system should be printing a URL.

Bottom line: The file is where it needs to be, but it's not being "seen" and I can't figure out why.

Any thoughts?
0
Comment
Question by:brucegust
3 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 250 total points
ID: 40513191
So if you try to use a constant and it doesn't have the value you expect, then it simply has not been defined. So the real question is why isn't it defined? My bet would be that includes.php is not pulling in paths.php correctly, so I would suggest adding code to REQUIRE paths.php and not just include it. So if it fails, it'll let you know about paths.php earlier.

Also, you really shouldn't use auto_prepend_file. It's going to apply to EVERY SINGLE php call that goes through your PHP setup, which is usually more than you actually want later on. It's better to just require the includes file in your code.
0
 
LVL 82

Assisted Solution

by:hielo
hielo earned 250 total points
ID: 40513332
>>In the php.ini file, we set the auto_prepend_file directive to point to /var/www/html/includes/includes.php
Well, the screen shot you posted seems to indicate that your site is actually hosted on a Windows system.  Whereas the comment that:
auto_prepend_file=/var/www/html/includes/includes.php

suggests that the developer set the "auto_prepend_file" option as if though you would ultimately host your site on unix-based system.  Thus, you most likely need to update "auto_prepend_file" so that it points to the right location of your includes.php file.  

Step 1.  Identitfy the full path to your includes.php file.  Based on your screen shot, my best guess is that it is in "C:\wamp\www\saw\includes\includes.php".

Step 2. Verify that the value of "auto_prepend_file" in php.ini matches that of Step 1.  To do so,
my suggestion to you is to create a file named "test.php" and put the following code in it:
<?php
phpinfo();

Open in new window

Then load it via your browser.  Look for the setting of "auto_prepend_file".  If its value does not match the path you identified in Step 1, then you need to update php.ini.  BTW, if you need to know where is your php.ini, search for "php.ini" on your browser after you have loaded test.php, since php.info() will reveal the path to your php.ini file.

After you have updated your php.ini file, restart the webserver.
0
 

Author Comment

by:brucegust
ID: 40514022
Thank you both! I was able to get it to work using both the remedies and the background info you two provided.

Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now