The Mother Board

Motherboards.org forums. Free tech support, motherboard ID, and more.
It is currently Wed Sep 26, 2018 2:59 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: PHP variable problem
PostPosted: Sat Apr 21, 2007 4:10 am 
Offline
Black Belt 1st Degree
Black Belt 1st Degree

Joined: Mon Dec 29, 2003 10:35 am
Posts: 1092
Location: Trapped inside a virtual machine.
Hope you guys can help. I'm trying to set up a program on my site but whenever it reaches the same variable, it stops. The files are PHP. Basically, I have a folder in the root dir called /admin, and another folder called /English, which is set in my admin panel as my default language. The beginning of each document with the problem looks like this:

Quote:
<?php
include("../config.php");
include("adminlib.php");
$textpart = "eventtypes";
include("../getlang.php");
include("../$mylanguage/admintext.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;
include("checklogin.php");


The problem is, when the server parses the file in question, I get the following errors, which seem to indicate that when the line in bold above is parsed, it's not read properly by the server (the variable $mylanguage seems to be missing):

Quote:
Warning: include() [function.include]: Unable to access ..//admintext.php in /usr/local/psa/home/vhosts/mysite.com/subdomains/family/httpdocs/admin/index.php on line 6

Warning: include(..//admintext.php) [function.include]: failed to open stream: No such file or directory in /usr/local/psa/home/vhosts/mysite.com/subdomains/family/httpdocs/admin/index.php on line 6

Warning: include() [function.include]: Failed opening '..//admintext.php' for inclusion (include_path='.:') in /usr/local/psa/home/vhosts/mysite.com/subdomains/family/httpdocs/admin/index.php on line 6


Any ideas? I'm not terribly brilliant at PHP so I might be missing something silly and obvious.

_________________
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 21, 2007 4:40 am 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
basically the problem is the setup of the file structures.... As it stands not the code is trying to find a file that does not exist....

Not sure how to go about it, but:
Code:
include("../$mylanguage/admintext.php");


Does not physically exist. The language folder is a seperate folder all together, and the admin file is not in that directory. I understand what you are trying to accomplish but do not know the coarse of action to get there.

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 21, 2007 4:44 am 
Offline
Black Belt 1st Degree
Black Belt 1st Degree

Joined: Mon Dec 29, 2003 10:35 am
Posts: 1092
Location: Trapped inside a virtual machine.
If I change ../$mylanguage/whatever.php to ../English/whatever.php, then it finds the folder it wants. The problem is that I want dynamic language choice, not to hardcode everything to be English.

_________________
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 21, 2007 5:29 am 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14301
Location: Maine
filecore wrote:
If I change ../$mylanguage/whatever.php to ../English/whatever.php, then it finds the folder it wants. The problem is that I want dynamic language choice, not to hardcode everything to be English.
Like I said I know what you want to do just dont know exactly how to do it.

But the problem is the way the code is being interpited, its trying to find a page in a folder named $mylanguage and not interpiting the $mylanguage as English.

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 21, 2007 11:43 am 
Offline
Black Belt 1st Degree
Black Belt 1st Degree

Joined: Mon Dec 29, 2003 10:35 am
Posts: 1092
Location: Trapped inside a virtual machine.
Incidentally, the PHP retrieves the language via this method:

Quote:
<?php
@ini_set( "session.bug_compat_warn", "0" );
session_start();
session_register('session_language');
session_register('session_charset');
$session_language = $HTTP_SESSION_VARS[session_language];
$session_charset = $HTTP_SESSION_VARS[session_charset];
if( $session_language )
$mylanguage = $session_language;
elseif( $HTTP_COOKIE_VARS[tnglangfolder] ) {
$mylanguage = $HTTP_COOKIE_VARS[tnglangfolder];
$session_language = $HTTP_SESSION_VARS[session_language] = $mylanguage;
$session_charset = $HTTP_SESSION_VARS[session_charset] = $HTTP_COOKIE_VARS[tngcharset];
}
else {
$mylanguage = $lang ? $lang : $language;
$session_language = $HTTP_SESSION_VARS[session_language] = $language;
}
if( !$session_charset )
$session_charset = $HTTP_SESSION_VARS[session_charset] = $charset;
?>

_________________
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 24, 2007 1:32 am 
Offline
Black Belt 1st Degree
Black Belt 1st Degree

Joined: Mon Dec 29, 2003 10:35 am
Posts: 1092
Location: Trapped inside a virtual machine.
I think I have a solution - apparently it's looking for the webserver root and not the account's root directory, so I need to append this before the include:

Quote:
$_SERVER['DOCUMENT_ROOT'].


Ie:

Quote:
include ($_SERVER['DOCUMENT_ROOT'].'/text.php');


I'll give it a try now...

_________________
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 11, 2007 3:15 pm 
Offline
Initiate
Initiate

Joined: Fri May 11, 2007 12:57 pm
Posts: 23
Location: Denmark
Dunno if you have solved your problem.

Line 6:
Code:
include("../$mylanguage/admintext.php");


Should proberly be:
Code:
include("../".$mylanguage."/admintext.php");


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat May 12, 2007 1:04 am 
Offline
Black Belt 1st Degree
Black Belt 1st Degree

Joined: Mon Dec 29, 2003 10:35 am
Posts: 1092
Location: Trapped inside a virtual machine.
Thanks, I'll give that a try at some point this weekend...

_________________
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group