Page 1 of 1

php.ini problem

Posted: Sat Jul 29, 2006 8:35 pm
by tk89121
I am trying to change some settings in my php.ini file. The whole file can be found here
http://code.bulix.org/1y87y7-11506

Ive only changed two things
display_errors = On
magic_quotes_gpc = On

The problem is neither seem to work when I run my scripts. Ive restarted apache, as well as my box trying to get php to reflect the changes.

Ive checked the phpinfo() and it says that the php.ini file is located in
etc/php.ini

This is the one that i have been editing, and the one that is posted on code.bulix

Ive also tried creating an htaccess with
php_value display_errors 1

in it but that didnt work either, can someone please help me ive been at this for hours and im at wits end

Posted: Sat Jul 29, 2006 8:47 pm
by jamiel
Are your setting changes reflected in phpinfo();

Posted: Sat Jul 29, 2006 9:04 pm
by tk89121
no the changes dont show up

Posted: Sat Jul 29, 2006 9:15 pm
by bdlang
Have you checked your apache server log to see if there is an error loading PHP?
This is your own server? What OS/Version? Is PHP installed by source or package?
Is the PHP install a part of your Apache install or seperate?
What permissions are on the php.ini file?
Where is the PHP install? '/usr/local'? Should the php.ini file be in /usr/local/etc/? or /etc/? or even /usr/local/php/etc/?

What specifically are you trying to do that can't be done with the following in a script:

Code: Select all

ini_set('display_errors', 1);
if ( !get_magic_quotes_gpc() ) {
    $_REQUEST= array_map('addslashes', $_REQUEST);
}
Yes, I realize these are hacks to perform a specific function (and you should really take a hard look at NOT using magic quotes but instead escaping all data with a specific function, especially if that data is headed towards a database).

Posted: Sun Jul 30, 2006 9:58 am
by Ambush Commander
Please run Feyd's diagnostic script and tell us the results:

Code: Select all

<?php

$neg = array(0, false, '', null, 'off');
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), $neg) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), $neg) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), $neg) ? 'Off' : 'On');
$le = '';
$cli = (php_sapi_name() == 'cli');
$eol = ($cli ? "\n" : "<br />\n");

$gle = get_loaded_extensions();
$rows = array();
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
    $le .= '   ' . implode('   ', array_slice($gle, $i, $wide)) . "\n";
}
if ($cli)
{
     $le = $eol . $le;
}
else
{
 $le = '<pre>' . $le . '</pre>';
}

$ec = array(
   'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
   'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
   'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
   'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
   if (($t & $v) == $v)
   {
      $e[] = $n;
      $t ^= $v;
   }
}
$er = $er . ' (' . implode(' | ', $e) . ')';

if (!$cli)
{
  echo '<html><head><title>quick info</title></head><body>' . "\n";
}

echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;
echo 'Loaded Extensions:' . $le . $eol;

if (!$cli)
{
  echo '</body></html>' . "\n";
}

?>
Furthermore, if PHP is installed as an Apache module, you will need to restart Apache before the changes go into effect.

Posted: Sun Jul 30, 2006 10:09 am
by RobertGonzalez

Code: Select all

display_errors = On
magic_quotes_gpc = On
Both of these can be manipulated code-side. Are you sure your scripts are changing these settings at run time?

Posted: Mon Jul 31, 2006 1:21 am
by tk89121
This is the output of the provided script

Code: Select all

PHP Version: 4.3.9
PHP OS: Linux
Error Reporting: 2047 (E_ALL)
Register Globals: Off
Short Tags: On
Display Errors: Off
Loaded Extensions:

   yp               xml              wddx             tokenizer     
   sysvshm          sysvsem          standard         sockets       
   shmop            session          pspell           posix         
   pcre             overload         mime_magic       iconv         
   gmp              gettext          ftp              exif          
   dio              dbx              dba              curl          
   ctype            calendar         bz2              bcmath        
   zlib             openssl          apache2handler   ldap          
   mysql
As for not using magic quotes, I agree that not using them is the better way to go but that is not an option for me. Furthermore there are other settings in my php.ini file that i would like to change.

My php.ini file is located in /etc as reported by php_info.

I already have restarted apache as well as the box multiple times

Thank you for your help so far in trying to resolve this problem

Posted: Mon Jul 31, 2006 9:52 pm
by RobertGonzalez
You may not be working in the proper php.ini. If you say you turned error_reporting on then you are in the wrong php.ini because the diagnostic says otherwise.