Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP page displays on ubuntu, not on Windows 7

Tags:

php

xampp

wamp

We've inherited a PHP page which runs fine on Ubuntu, but dumps source code onto the display on a Windows 7 system running either XAMMP using PHP 5.4, or WAMP using PHP 5.3.

The point where the dump occurs seems to be when it tries to parse a "->" (object property) character combination. When I change that to "[]" to access as an array element, it gets past that, but then dumps source code onto the display which appears after the "=>" (mapping) character combination. Commenting that out doesn't work, only deleting the whole line gets it past there.

Finally, when it's just printing out html with "<" and ">" signs, that also causes the screen dump. If I replace those characters with the html entities, the source code doesn't dump any more, but the program doesn't display the menu and doesn't function at all. Note that I can successfully log into the app via it's login page, although even that displays "POST" and some other "<" and ">" characters in the username field.

I've tried running unix2dos on the whole app, but that didn't have any effect. Also tried converting the text of one of the offending pages to UTF-8, but still no luck.

In answer to some of the questions posed:

The working ubuntu version is PHP Version 5.3.10-1ubuntu3.1

The first piece of code that works in Ubuntu and not in Windows is this:

public function __construct($gid)
{
    $this->id = $gid;
    return $this->retrieve();
}

where the code dump onto the display starts with:

id = $gid; return $this->retrieve(); }

Yes, PHPInfo does work, showing for the WAMP server with PHP Version 5.3.13

I tried changing the short-open-tag but it made no difference.

The product was written for us by an outsourcing group, and it appears to be based on some kind of framework. But I couldn't find any references to any of the classnames on Google, so maybe they wrote the whole thing in-house.

Going to the apache log, the actual error happens on this line:

$_SESSION['admin_gid'] = Membership::getGroup($rUser['id']);

where the error message is:

Membership' not found

Membership is a class which is declared later in the same file as the one getting dumped on the display at the point shown above, so for some reason the PHP parser doesn't understand it's reading PHP code from that point.

like image 267
Jack BeNimble Avatar asked Jan 22 '13 13:01

Jack BeNimble


1 Answers

I tried changing the short-open-tag but it made no difference.

In a scenario like this what you can do is write a small script and run it and see whether it works. try short tag and below method. Keep in mind that if you mess with your php.ini you will have to restart the server. It's better to change the setting by right clicking on the server icon on the task-bar. It could be due to php short tags. Try enabling and disabling and running the script. Also change the below script and see how that affects with your changed settings.

EG :

<?php
echo "hi";
// phpinfo(); <-- preferred if you can
?>

Then you can see whether your server is working you as intend it to. If it O/P hi you are good to try your big code and see.

By the way code which you have provided does not seems have errors.

like image 52
Techie Avatar answered Sep 30 '22 13:09

Techie