Solved

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

Posted on 2014-12-22
3
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
embadded search engine in website 4 46
Change Wording in Wordpress Plugin 4 38
JSON decode 5 44
Windows 10, 64 bit WAMP - won't start 9 28
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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