Solved

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

Posted on 2014-12-22
3
126 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 35

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

713 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