PDA

View Full Version : A link problem


2bz2p
06-25-2008, 12:01 PM
Hi,

I know this sounds stupid but here goes, I have config.php which does all the db connections and adds a couple of common variables. This file sits in the root folder of the program. now I also have a toolboxes.inc.php file in my includes file, this creates the navigation via functions. Last night I was working on one of the admin pages which I would like to put in an admin folder, though when I do that i get a host of issues.

The Toolboxes give me an sql error because it cant find the config file and when I change the link to reflect the path of the config file, the admin nav bar works though user end stuff doesnt. So with out having to create an admin config file and an admin toolboxes, how do I get the config file to be seen regardless of which folder the page is coming from.

I hope yall understand what my delema is
Thanks
2b

davidj
06-25-2008, 12:35 PM
its all to do with your paths

you must be missing a path which has not been changed

2bz2p
06-25-2008, 03:38 PM
Thanks for the Reply,

Alright cool, then I just need to make sure that a) DW doesnt edit any of my paths or what it calls updates. b) check the all the paths.

Now let me ask you this, I have and include includes/toolboxes.inc.php on every page. When the toolboxes file is run this way what is the actually folder its running from example being

root/index.php
index has the include so are the links in the toolbox changed to
root/toolboxes.inc.php
or is it still this
root/includes/toolboxes.inc.php
regardless of where the file sits that includes it.

Hope that makes sense
2b

davidj
06-25-2008, 05:32 PM
if you have the following

dir -> includes

file1.php
file2.php
file3.php

index.php
page1.php
page2.php


to include file1.php into index.php or page1,2.php the path structure would be...


include("includes/file1.php");

2bz2p
06-25-2008, 06:45 PM
I do understand that aspect though this is what I mean


dir -> includes

file1.php
file2.php
file3.php

index.php
config.php
page2.php


Now Index.php has this include
include ('includes/file1.php')

and File1.php has this include

include ('config.php')


so is config.php still running from the root even though it is an include of another file in the includes directory?

davidj
06-25-2008, 06:55 PM
your config should be


include ('../config.php')


if your wanting to include a file above the dir the file is in

2bz2p
06-25-2008, 06:58 PM
okay sounds good I am going to run through all my links and paths to make sure thier right

Thanks
2b

davidj
06-25-2008, 06:59 PM
remember 2 dots (..) move you up a level

2bz2p
06-25-2008, 10:16 PM
Alright so I have tried every which way from sunday


file structure

root/config.php
Root/pirep.php
root/admin/admin_edit_hubs.php
root/includes/toolboxes.inc.php


first is first the include file
toolboxes.inc.php

When the code looks like this:

function user_info_box(){

include ('../config.php');

session_start();
include ('../includes/security.inc.php');

$callsign = $_SESSION['callsign'] ;

/*Get info from db about the pilot*/

mysql_select_db($database_conn_abrv, $conn_abrv);
$query_pilot = "SELECT * FROM pilot WHERE callsign = '$callsign' ";
$pilot = mysql_query($query_pilot, $conn_abrv) or die(mysql_error());
$row_pilot = mysql_fetch_assoc($pilot);

$user_i_box = array(
'logout' => '<a href="logoff.php"><strong>Log Out</strong></a>');


echo '<div id="pilot_info_box">';
echo "<h2>User Panel</h2>";
echo "<p><strong>Name:</strong>";
echo $row_pilot['name'] ;
echo "</p>" ;
echo "<p><strong>Call Sign:</strong>";
echo $row_pilot['callsign'] ;
echo "</p>";
echo "<p><strong>Flight Hours:</strong>";
include('../includes/total_hours.inc.php') ;
echo "</p>";
echo "<p><strong>Total Flights:</strong> ";
echo $row_pilot['flight_serial'] ;
echo "</p>";
echo "<p><strong>Rank:</strong>";
include('../includes/ranks.inc.php') ;
echo "</p>";
echo "<p><strong>";
echo $user_i_box['logout'] ;
echo "</strong></p>";
echo '</div>';

return;
}

more navigation functions here, but none that have includes.


the root/admin/admin_edit_hubs.php works out and displays what it is supposed to
though the Pirep.php shows this error


Warning include(../config.php) [function.include (http://localhost/vpilot/function.include)]: failed to open stream: No such file or directory in C:\wamp\www\vpilot\includes\toolboxes.inc.php on line 33


Now if I go into the toolboxes and change the ../ to blank like this


include ('config.php');

session_start();
include ('includes/admin_security.inc.php');
include ('includes/toolboxes.inc.php');


The Pirep.php works fine but the admin_edit_hubs.php give this error

Warning: include(config.php) [function.include (http://localhost/vpilot/admin/function.include)]: failed to open stream: No such file or directory in C:\wamp\www\vpilot\includes\toolboxes.inc.php on line 33


This is why I brought up the link issue because I thought I was doing the links wrong, but I dont know what is happening here nor do I know how to correct it.

It almost makes me want to get rid of the pilot info section, though I dont want to have to change every file when I make a change.

Thanks
2b

davidj
06-25-2008, 10:35 PM
you have complicated such an easy setup

create an include dir and anything that is included delve into that

save all your includes into that dir

2bz2p
06-25-2008, 10:56 PM
I have an include directory and everything that is included is their except the config.php (which is my connection piece) or should that be in there too?

davidj
06-25-2008, 10:57 PM
everything that is included should be in there

i create a connection dir and store my connection / config file in there

2bz2p
06-25-2008, 11:00 PM
yeah I just added the config.php file to the includes directory and everything worked, shoot me now, its the only setup I didnt try lol.

I gues when it came down to it I didnt look at the config as an include even though it is.

Thanks man
2b