Jump to content

Weird behaviour.


Lysdexic

Recommended Posts

I have a development machine running WAMP on a win7 64 bit box. php 5.3.13

I have a server that runs Apache 2.2, php 5.3.12 MySql, etc.

 

I am running joomla 2.5.27 on both machines.

I require a number of php includes to many of the joomla articles (this works great via a plugin called Directphp)

 

After considerable time getting the site fully working on the dev machine, I ran into an unforseen problem when I uploaded to the production box.

For some unknown reason, the includes work fine on the dev machine using $DOCUMENT_ROOT to define the root (then tag the correct path and file to this)

However, on the production box, this doesn't work - but...  $_SERVER['DOCUMENT_ROOT'] does.

 

Annoyingly, $_SERVER['DOCUMENT_ROOT'] won't work on the dev machine - and $DOCUMENT_ROOT doesn't work on the production box.

 

So, I can't come up with a generic method to keep both machines happy.

I've checked the php.ini files on both boxes and the register global is OFF on both.

 

They also seem to interperate the syntax differently in the actual include files - one box hates double quotes - the other has issues with single quotes.

This is really annoying as most of the includes are HTML snippets, coded into php.

The double/single quote problem means I would need to have two versions of the include files.

 

Can anyone help me with this? - serious hair pulling has started!

 

 

 

 

Link to comment
Share on other sites

I've checked the php.ini files on both boxes and the register global is OFF on both.

 

 

what does the output from a phpinfo(); statement show for register_globals (the php.ini that you are looking at may not be the one that php is using)?

 

 

So, I can't come up with a generic method to keep both machines happy.

 

 

just use $_SERVER['DOCUMENT_ROOT'] in your code and assign it the value in $DOCUMENT_ROOT on your development system. don't assign it any value on the live server. however, that $DOCUMENT_ROOT has a value means that register_globals is likely on (see above to actually check using a phpinfo() statement.)

 

the type of quotes being used in an included file would not matter. there must be something else going on that's causing the problem. you would need to tell us what - "one box hates double quotes - the other has issues with single quotes." actually means in term of symptoms and error along with a sample of the offending code, since computers don't have hate issues with code.

Link to comment
Share on other sites

Hi,

 

Thanks for the quick reply.

 

Both boxes show globals are OFF in the phpinfo output page.

I looked at the php variables section to see what each version thought the document root should be.

 

In the dev box, the value was c:/wamp/www

In the priduction box, it was home/john001/public_html

 

As you have indicated, this is where the main problem lies, since the dev box ends at 'www' (and there should be a further step to the folder where the site is located)

The production box is fully pointing to the public_html folder where the live site is located.

 

To check, I used the $document_home method on the dev box and it found the path straight to the local site.

When I switched to $_server[Document_Root] on the same box, the file couldn't be found (because the path stopped one level short at 'www')

To confirm this, I added the missing folder name to the string that followed the php variable - and it worked :)

 

So, to recap - the dev box understands $_server[Document_Root] - but it reports a path that is one folder short of where the local site is located.

The production box has the correct pathway and finds the required include file every time.

 

I'm assuming the WAMP setup has to be flexible to allow multiple development sites on the same box, so it only has a path that goes to the 'www' folder (the place where all the sites are stored in their own project folders).

 

As you suggest, I'll tweak the dev box to report that extra step to the local site folder.

This will make the same code work on both machines and we are back in business :)

 

Now that this is working again, I'll take a closer look at the quotes issue - it might be due to the plugin that intercepts the embedded php in the Joomla article.

 

Thanks for the help - you nailed it in one sentence :)

 

John

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.