We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

newbie developer question

Development and Programming

cbad's avatar
cbad
60 posts
13 years ago
cbad's avatar cbad

Hello-

I’ve just written my first non-trivial plug-in, and everything went really smoothly on my localhost machine (WAMP). This is a private plugin, and I want to include some scripts we use elsewhere.

But when I uploaded it to the servers (LAMP), the page won’t show at all. In Chrome it shows as a 330 error, but that seems to be sort of a catch-all.

I’ve traced it down to (at least) one line in the plugin:

require_once $_SERVER['DOCUMENT_ROOT'].'/phpglobals.php';

Like I said, it works great on my local dev machine. Is this not allowed in a plugin, or do you think there is some sort of config or server setting that prevents this working?

I’ve verified the paths and files all exist. We use this same file in other php scripts all over the place, addressing it in the same way.

Any ideas? I’m splitting hairs trying to understand it.

Thanks!

       
siffring's avatar
siffring
147 posts
13 years ago
siffring's avatar siffring

You might want to turn on error reporting to see what the issue is.

error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

(You may need to add that to index.php.)

Also, try echoing the path to see what it comes up as in the server (just to make sure it looks right).

echo $_SERVER['DOCUMENT_ROOT'].'/phpglobals.php';

I’d also check the file permissions on the file to make sure it’s readable and executable.

       
cbad's avatar
cbad
60 posts
13 years ago
cbad's avatar cbad

Thank you for the response. I’ll turn on the error reporting and check file permissions.

Is there some reason permissions need to be different in EE addons as opposed to normal php execution? Like I said, we access this file from other places no problem.

I also had checked the path and file both exist. Hopefully permissions may be the answer.

Thanks!

       
cbad's avatar
cbad
60 posts
13 years ago
cbad's avatar cbad

Found the problem. In the file I was including, there was a line feed after the closing ?> that was causing the error. It was messing with the header, thus causing the browser error. Never got a php or EE error though.

Anyway, thanks for your help, it got me looking in the right direction!

       
JCloutier's avatar
JCloutier
10 posts
13 years ago
JCloutier's avatar JCloutier

It usually best practice to leave the closing ‘?>’ off so you can avoid those situations in pure php files. They can be very frustrating and time consuming to track down 😖

       
cbad's avatar
cbad
60 posts
13 years ago
cbad's avatar cbad
It usually best practice to leave the closing ‘?>’ off so you can avoid those situations in pure php files.

Good advice. PHP makes that closing tag optional in such cases anyway. I should have known better. 😉

Thanks!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.