Page 1 of 1

opening URL as file/overwriting php.ini on the server

Posted: Sun Mar 26, 2006 8:27 pm
by konstantin
i'm trying to use simplexml_open_file() function to process an Amazon response, BUT:

altough the file works fine on my machine, when i try to open the page i get:

Code: Select all

Fatal error: Call to undefined function: simplexml_load_file() in /homepages/...
obviosly that's the kind of error when the server is not running PHP 5... well, the thing is that it is for a fact running PHP 5, and i renamed the extension of my file from .php to .php5. i can load the file, but i get:

Code: Select all

Warning: simplexml_load_file() [function.simplexml-load-file]: URL file-access is disabled in the server configuration in  /homepages/...
my understanding is that i need the

Code: Select all

allow_url_fopen = On
in the php.ini on the server. i read somewhere that you can overwrite the ini like this:

Code: Select all

ini_set("allow_url_fopen", "On");
but it doesn't work... any suggestions? thanks.

Posted: Sun Mar 26, 2006 8:40 pm
by josh
Set the entry in your php.ini or httpd.conf

See here: http://us2.php.net/manual/en/ini.php#ini.list

only some options can be overridden by ini_set, if .htaccess is allowed you can do it that way too

Posted: Sun Mar 26, 2006 9:10 pm
by konstantin
what does PHP_INI_SYSTEM mean when it comes to overwriting the setting on the SERVER ini file from your loaded php file?

Posted: Sun Mar 26, 2006 9:13 pm
by josh
its right there on that link, plus i told you in my previous post. .. please try to show some initiative

Posted: Sun Mar 26, 2006 9:17 pm
by feyd
PHP_INI_SYSTEM: Entry can be set in php.ini or httpd.conf

Your host likely turned it off due to security problems. Try looking at using cURL or fsockopen() to fetch the file then use the string parsing of the functionality you want to handle the data returned.

Posted: Sun Mar 26, 2006 9:25 pm
by konstantin
sorry, i didn't scroll all the way down...

now my understanding is that i can't overwrite the setting through the script in my file, as the php.ini is on the hosting company's server... :(

Posted: Sun Mar 26, 2006 9:31 pm
by josh
is .htaccess disabled? is curl available? are sockets disabled? you could open a socket and do a http request manually, you could use curl to grab the page, you could ask your host to overide the setting the setting in httpd.conf for just you (and tell them theyll loose your business if you don't).

I hear VPSs are good ;-)

Posted: Sun Mar 26, 2006 9:47 pm
by konstantin
everything worked great on my laptop until it decided to crash 2 days ago... i'm working on a school project and i'm supposed to show my progress. since i no longer have my laptop to present, i'm forced to make the project run on a server... a friend of mine is running a server, together with some other people, and was kind enough to assist me with providing me some space and doing some settings for me. i'm not paying anything for this so i can't force him to change ini settings. i guess he'll talk to the other people and let me know...

since i'm a total PHP n00b, i just don't see how i can use cURL or fsockopen() to fetch the file at this point. but thanks for your help anyway.

Posted: Sun Mar 26, 2006 10:55 pm
by josh
konstantin wrote:i just don't see how i can use cURL or fsockopen() to fetch the file at this point.
there's a good example on the man page: http://us2.php.net/fsockopen

Posted: Mon Mar 27, 2006 7:19 pm
by konstantin
ok, i got the fsockopen() to work and now i have a variable $result, that's a string starting with the '<?xml...' tag.

as i mentioned in my initial post, i used simplexml_load_file() before to take care of the fetching (i.e. do all the work). now that i have that string variable, how do i fetch it so that i can access the attributes?

thanks,
k

Posted: Mon Mar 27, 2006 7:45 pm
by feyd

Posted: Mon Mar 27, 2006 8:07 pm
by konstantin
OMG, wish every problem had such an easy solution.

Thanks much!