I have had to switch to a new development machine recently thus have had to reinstall WAMP (latest build).
The website I’m working on loads fine on localhost except for one issue which I think is related to PHP (maybe Apache but I’m swaying towards PHP).
My sendmail.php file won’t load in the browser. In Chrome (IE does the same) I get a “This web page is not available.” and error code “Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.”
I’ve been trying to dig my mind what causes this. All I can remember at this stage is that sendemail.php had to be processed in PHP5 (not version 4.xx) else it will throw errors. I can’t however remember if it’s this error that caused me to force PHP5. I usually make a note of major issues to remind me what to do if I need to reinstall. On this occasion I didn’t (for whatever reason…something for me to dwell on later).
In my .htaccess I have the following line which should force PHP5:
# Force PHP5
AddType x-mapp-php5 .php
If I remove the above line then all pages (except for sendmail.php) load correctly on localhost. If I keep the above line in .htacesss the the browser (any) on localhost will simply display the source code (text) of each PHP file. Obviously I had to add this line for the “online” workings of the site.
All this works fine online (i.e. on the web server. also running PHP 5.xx - 5.26 I think) which just emphasises it’s something to do with WAMP or more specifically PHP or Apache.
Any ideas anyone? I’ve been looking through php.ini to see if anything rings a bell but it would seem my brain has lost thought on the what, where and why.
Further to the above I’ve run the page in Safari and it throws this error, which may be more descriptive to someone:
Safari can’t open the page “http://localhost/sendemail.php”. The error is: “cannot decode raw data” (CFURLErrorDomain:-1015) Please choose Help > Report Bugs to Apple, note the error number, and describe what you did before you saw this message.
I will try and investigate. I do think it’s WAMP but more specifically the PHP “component” found within WAMP. I also know it worked fine in WAMP on the old machine. I think I just had to change a line here or there in one of the .ini o .conf files (can’t remember what or where though).
The fact the sendmail.php file works fine online suggests it’s indeed not its source code (which I didn’t change anyhow) but rather WAMP related.
Thanks,
UPDATE: Installed EasyPHP, copied website to WWW folder, did a localhost in IE and same problem. Sendmail.php still won’t load when I click through from contact.php. EasyPHP does however seem to be setup differently since I didn’t have to remove the below lines from my .htaccess file to get the website to load (in WAMP this is a must for offline localhost testing etc.):
# Rewrite enabled
RewriteEngine On
RewriteRule ^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.phtml$ index.php?id=$1,$2,$3,$4,$5,$6
RewriteRule ^(.+)\\.phtml$ index.php?$1
# Deny stealing content (no hot linking)
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*jpeg$|.*gif$|.*png$|.*ico$|.*js$|.*css$|.*txt$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\\.)?websiteaddress\\.co.uk/ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.websiteaddress\\.co.uk/.*$ [NC] [OR]
RewriteRule (.*) /nohotlink.php?pic=$1
# Enable caching static files - 1 day
<FilesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=43200, public"
</FilesMatch>
# Force PHP5
AddType x-mapp-php5 .php
Sounds like the content was encoded improperly. content encoding usually refers to compression like gzip or deflate.
Have you done any debugging? rip your script apart and strategically put it back together. This usually lets you get close to the problem in a few minutes. use the webserver and php error logs to help you.
Yes. It seems I’ll have to break it down part by part and see where it throws the error from (what line of code) if I can’t pinpoint it down via this forum.
The strange thing is that I didn’t change the source code in this specific file when moving from the old to new development machine. It’s exactly the same yet throws the above error.
All my PHP files make use of the below for compressing the text in real-time. All other files except for the sendemail.php work (show) as expected in a browser hence it’s something in PHP/Apache.