views:

75

answers:

5

I'm running php vs. 4.1.14 on yahoo with phpMyAdmin. it says the file is at /usr/lib/php/php4.ini but I can't find this anywhere. Is it in the phpMyAdmin folder? I really need to find this and turn of magic_quotes soon or I'm gonna go postal. Thanks.

Okay So i guess It wasn't that clear. I did phpinfo(). I don't know how to find that location on the server.....

+3  A: 
  1. Do a phpinfo(): It will tell you the exact full location of the php.ini used.

  2. You should not be using PHP 4 any more. :)

Pekka
I know but I can't figure out how to update it. Also I did phpinfo() and it gave me /usr/lib/php/php4.ini . I don't know where that is on the server.
creocare
I'm also retarded, so I got that going for me.
creocare
@creocare it is an absolute path. Where/how are you trying to open it?
Pekka
I tried getting there using filezilla
creocare
@creocare that probably won't work because FTP access is usually restricted to the web folder. You'll need SSH access to the machine (you can use WinSCP then). You'll probably need root access to modify the file
Pekka
Yeah I'm on a mac. I guess I'll try fugu.
creocare
A: 

If you create a new PHP file with:

<? phpinfo(); ?>

Then it will show you which php.ini file is loaded

Jonathon
A: 

You don't have to turn off magic quotes, just stick this at the top of every page:

function FixMagicQuotes()
{
    if(get_magic_quotes_gpc())
    {
        foreach($_POST as $key => $value)
        {
            $_POST[$key] = stripslashes($_POST[$key]);
        }
    }
}

FixMagicQuotes();

It will do nothing if magic quotes is disabled. If it is enabled, it will loop throught the POST fields, stripping slashes from each entry.

George Edison
can I just use this on the last page before uploading it to the db?
creocare
A: 

The path you found in phpinfo

/usr/lib/php/php4.ini

is path on the server of your hosting account. The forward slash at the beginning of the path indicates it's a path from the root level of the file system. Think of this like the C:\ folder on a windows machine.

If you have SSH access to the server you can edit this file with a command line editor ("pico" is the easiest to learn)

$ pico /usr/lib/php/php4.ini

If you're using an sFTP client you should have a command (possibly a button or a drop down menu) that is something like "Go to Folder" or "Go to Directory". This should allow you to enter the path

/usr/lib/php/

which will drop you in the folder with php.ini.

Also via sFTP, when you log in you should see the ".." folder. Clicking on this will move you up a directory from your home directory. Keep click on this until you get to the top, then drill down to

/usr/lib/php

If you're accessing this through a file share of some kind, you're out of luck. Your system admin has effectively locked you out. Also, the above techniques may not work if the administrator of the server has blocked access to these folders and files (often common and necessary in a shared hosting environment)

Alan Storm
+1  A: 

Finding php.ini on a dedicated server can be done easily by phpinfo (as others said)

But I think you're using a shared hosting environment (so you can not edit php.ini) and actually need to turn off magic_quotes_gpc. (Am I right?) If so, simply create a file named .htaccess in the web root (or phpMyAdmin root) and put the following line in that.

php_flag magic_quotes_gpc off  

Hope to help :-)

Ehsan