Server PHP problem

Soldato
Joined
18 Oct 2002
Posts
10,188
In another thread I created a function that uses a get_header() on a url to find out song names from a streaming service. It works well, however I have encountered a problem on my hosting that I cannot solve.

It is on Stablepoint, I have contacted their chat support and I must say I am very very very disappointed in their help, so much so I have had to turn to here. They claim that the code is at error. I have tested this is not the case as I have 2 hosting comapanies and it works on the other and on my local...

What I cannot work out is what is the problem on Stablepoint. I am using the same PHP versions, 7.3.
There are a lot of Extension options i can enable but I do not know what any of them do.
The problem seems to be with the function calling the url, which is being blocked somehow or not working at all. It is not returning any data for the javascript to update the DOM. Initially it just returned a 500 error, I have since tried a different method and that doesn't return any data at all, both suffer from not being able to get the data from the URL.

I really am at a total loss what to do. Stablepoint won't help, they keep suggesting I use their sister company wordpress-fix (or something), but I know it's not my code. I have checked the error logs but nothing is showing up there either.

Any suggestions would be greatly appreciated.
 
...get_header()..

Do you mean PHP's function 'get_headers()' (https://www.php.net/manual/en/function.get-headers.php)?

Have you checked the PHP log file to see what error is being thrown? If so, what's the error?
You might need to set the error reporting level to 'E_ALL', which you can do via PHP.ini.

Also, does the "url" you're calling have a valid SSL certificate (if you're using HTTPS)?
As you can run into issues with invalid certificates which will throw an error; although you can pass options stream context options (using stream_context_create()) to get_headers() to try and get around them.

Might be worth trying fopen() and then using stream_get_meta_data(), which should return similar data, purely as the interpreter handles that differently to get_headers().

And worth doing a phpinfo() on both hosts and comparing, just to see if there's anything obvious.

Edit - IIRC, get_headers() relies on allow_url_fopen being enabled and some hosts disable this by default; can easily check via phpinfo() or looking at your PHP.ini file.
 
In another thread I created a function that uses a get_header() on a url to find out song names from a streaming service. It works well, however I have encountered a problem on my hosting that I cannot solve.

It is on Stablepoint, I have contacted their chat support and I must say I am very very very disappointed in their help, so much so I have had to turn to here. They claim that the code is at error. I have tested this is not the case as I have 2 hosting comapanies and it works on the other and on my local...

What I cannot work out is what is the problem on Stablepoint. I am using the same PHP versions, 7.3.
There are a lot of Extension options i can enable but I do not know what any of them do.
The problem seems to be with the function calling the url, which is being blocked somehow or not working at all. It is not returning any data for the javascript to update the DOM. Initially it just returned a 500 error, I have since tried a different method and that doesn't return any data at all, both suffer from not being able to get the data from the URL.

I really am at a total loss what to do. Stablepoint won't help, they keep suggesting I use their sister company wordpress-fix (or something), but I know it's not my code. I have checked the error logs but nothing is showing up there either.

Any suggestions would be greatly appreciated.

Hey, i'm one of the senior team at Stablepoint. Can you message me [email protected] with your site name and if you had a ticket before the ID? I'll help you track this down.
 
The problem seems to be with the function calling the url, which is being blocked somehow or not working at all. It is not returning any data for the javascript to update the DOM. Initially it just returned a 500 error, I have since tried a different method and that doesn't return any data at all, both suffer from not being able to get the data from the URL.

Do you mean the 500 error was returned from the url called by the get_headers method or by the page with the get_headers code on it? If the url called returned a 500 error then it's probably not blocked.
I'd set up a test site somewhere else which always returns known header values and test with that url.

edit: looks like daz is in a better position to help!
 
I'll contact Darren, thanks

I'll try to answer the question you said.

Do you mean PHP's function 'get_headers()' (https://www.php.net/manual/en/function.get-headers.php)? Yes, but I'm not even sure that's the problem. I have a function that can use 3 different methods and none of them seems to get through to the url
https://github.com/KO-N/Mp3StreamTitle/blob/master/Mp3StreamTitle.php


Have you checked the PHP log file to see what error is being thrown? If so, what's the error?
You might need to set the error reporting level to 'E_ALL', which you can do via PHP.ini.
I have checked the php settings and they are meant to be send error logs to the cpanel error file but I cannot see any at all, has made me wonder if the server is being blocked rather than blocking

Also, does the "url" you're calling have a valid SSL certificate (if you're using HTTPS)? yes it does but im using http
As you can run into issues with invalid certificates which will throw an error; although you can pass options stream context options (using stream_context_create()) to get_headers() to try and get around them.


Edit - IIRC, get_headers() relies on allow_url_fopen being enabled and some hosts disable this by default; can easily check via phpinfo() or looking at your PHP.ini file.
I've checked in the php ini and its enabled
 
@ChroniC - Hopefully Daz can help as that is an odd one. Although i'd be making sure, test with using the error_log() function in a test script somewhere, you're able to locate and read the PHP log file as i would have thought it'd throw an error message with CURL/sockets.

Obviously make sure CURL and 'Sockets' are enabled, usually they are but worth checking all the same via PHP info.
 
Darren has managed to sort this for me. Appreciate him going the extra mile. Handy having someone from Stablepoint on the forum. I'll try not to ask to many questions. :D
 
Last edited:
Thanks for the kind words ChroniC. :) If anyone else has a similar issue, it turns out it was a (server) firewall issue in the end. The script was trying to connect out to a port that isn't enabled outbound by default, so once that was added everything worked.
 
Back
Top Bottom