Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sort Multidimensional Array 11 34
Hacked File Timestamps 4 49
converting numbers with php 3 27
How do I randomize photo images before i move them to the path file? 9 20
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

919 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

21 Experts available now in Live!

Get 1:1 Help Now