Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 05:41 am EST
Geeklog Forums
Php and magic quotes
anonymouse
Anonymous
Sorry its not strictly geeklog related but its stopping me working on my plugin project. This is my first real php project so forgive me it this is a newbie question
I have the following code
$dir = dirname(__FILE__);
require_once($dir . '..\config.php';
For some reason php inists this evalutes to $dir ."..\\config.php"; - Im familar with the concept of special escaped characters like '\n' from c++ so I suspect it to be php magical quote problem.
I have checked php.ini magic_quotes_gpc,magic_quotes_runtime,magic_quotes_sybase are off
phpinfo() confirms this
I have wrapped the coded in the following lines
$X = ini_set (magic_quotes_gpc ,0);
$Y = ini_set (magic_quotes_runtime ,0);
$Z = ini_set (magic_quotes_sybase , 0);
set_magic_quotes_runtime(0);
$X = ini_set ('magic_quotes_gpc' ,0 );
$Y = ini_set ('magic_quotes_runtime' ,0);
$Z = ini_set ('magic_quotes_sybase' , 0);
but none of them seem to stop it evaluating to "..\\config.php" - which the include statement then complains about.
Can anyone tell me the correct way of disabling this - Ive lost a whole day on this now :-(
Thanks For your help
I have the following code
$dir = dirname(__FILE__);
require_once($dir . '..\config.php';
For some reason php inists this evalutes to $dir ."..\\config.php"; - Im familar with the concept of special escaped characters like '\n' from c++ so I suspect it to be php magical quote problem.
I have checked php.ini magic_quotes_gpc,magic_quotes_runtime,magic_quotes_sybase are off
phpinfo() confirms this
I have wrapped the coded in the following lines
$X = ini_set (magic_quotes_gpc ,0);
$Y = ini_set (magic_quotes_runtime ,0);
$Z = ini_set (magic_quotes_sybase , 0);
set_magic_quotes_runtime(0);
$X = ini_set ('magic_quotes_gpc' ,0 );
$Y = ini_set ('magic_quotes_runtime' ,0);
$Z = ini_set ('magic_quotes_sybase' , 0);
but none of them seem to stop it evaluating to "..\\config.php" - which the include statement then complains about.
Can anyone tell me the correct way of disabling this - Ive lost a whole day on this now :-(
Thanks For your help
5
4
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
Text Formatted Code
require_once $dir . '../config.php';
Windows will work with forward slashes.
If you want to be pedantic:
Text Formatted Code
require_once $dir . '..' . DIRECTORY_SEPARATOR . 'config.php';
Oh, and leave the parentheses off of require_once. It is not a function. It is a directive.
5
7
Quote
anonymouse
Anonymous
Thanks for the help. Once I get this plugin in working i can see its going to get rewrittem again from the ground upwards with what I have learned.
Then Im not too proud to admit I supsect somebodies going to tell me how I should have coded it :-) - still thats how you learn.
Once again thanks for the help
Then Im not too proud to admit I supsect somebodies going to tell me how I should have coded it :-) - still thats how you learn.
Once again thanks for the help
5
6
Quote
All times are EST. The time is now 05:41 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content