porting PHP from Linux
Posted by: thegerm (---.sunsh2.vic.optusnet.com.au)
Date: September 27, 2012 02:03PM

G'day all,

I have just tried to port some PHP/MYSQL code from a Linux (Ubuntu 12.04) server to WAMP server. This code works fine on the Linux box.

First attempt is a dismal failure. OK, I know the access to the Database will fail cos the code has local references, but that is not what worries me.
The main problem is that the web pages do not render correctly. Part of the PHP code is shown on the resulting web page. Tables get drawn OK, but their contents is shown as the PHP variable names.

This is the first few lines of the html/php :
------------------------------------------------
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"[www.w3.org]\">
<html>
<head>
<title>BHA Web</title>
</head>
<body bgcolor=#CFFFC6>
<h1>BHA-CMS - Test of All DB direct access functions </h1>
<?php

include 'BUS_functions.php';
include 'one_off_functions.php';
//-----------
print "<h2>BHA-CMS - Test of Person functions STARTED</h2>\n\n";
print "<p>1 - Write to Database\n\n";
$first_name = 'BHA-'.rand(0,999);
$surname = 'Surname-'.rand(1000,1999);
$postcode = '3'.rand(0,999);
$sex_code = rand(1,9);

$result = add_New_Person_Data('Mr', $first_name, 'George', $surname, '1 Silly St',
'', 'Dopeyville', 'Vic', $postcode, '1950-01-01', 'N',
'03 1234 5678', '0400 000 000', 'fred@nurcks.com.ru', $sex_code, '2010-01-27',
'Australia', 'Yellow Pages', 'blah blah') ;

print "<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new person entry added has person_id of : " . $result."\n" ;
--------------------------------------------------------------

and then this is what is displayed :
--------------------------------------------------------------
BHA-CMS - Test of All DB direct access functions
BHA-CMS - Test of Person functions STARTED\n\n'; print '

1 - Write to Database\n\n'; $first_name = 'BHA-'.rand(0,999); $surname = 'Surname-'.rand(1000,1999); $postcode = '3'.rand(0,999); $sex_code = rand(1,9); $result = add_New_Person_Data('Mr', $first_name, 'George', $surname, '1 Silly St', '', 'Dopeyville', 'Vic', $postcode, '1950-01-01', 'N', '03 1234 5678', '0400 000 000', 'fred@nurcks.com.ru', $sex_code, '2010-01-27', 'Australia', 'Yellow Pages', 'blah blah') ; print "

new person entry added has person_id of : " . $result."\n" ; print "
--------------------------------------------------------------

Anybody have any idea what is going wrong here. I have checked the error logs, but there there is no relevant info.

Any help greatly appreciated.

..Paul
Melbourne, Australia

Options: ReplyQuote
Re: porting PHP from Linux
Posted by: RiggsFolly (---.as13285.net)
Date: September 27, 2012 02:36PM

Silly question but you are running this through a browser arnt you? You are not clicking on a file name in explorer are you?

When you get php displayed in the browser in means that Apache has not passed the file through the PHP interpreter.
As you have the proper <?php tag it should be fine ( WAMP does not have short-tags turned on by default).

Questions:

Have you messed with the apache httpd.conf file?
Have you got a .htaccess file in your copied site that is causing a problem?
Have you turned off the php5_module (wamp->apache->apache modules->php5_module
Have you got "engine = On" in php.ini (wamp->php->php.ini)

Options: ReplyQuote
Re: porting PHP from Linux
Posted by: stevenmartin99 (Moderator)
Date: September 27, 2012 02:38PM

I don't see an error there , but maybe in these files

include 'BUS_functions.php';
include 'one_off_functions.php';

Can u paste these?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: porting PHP from Linux
Posted by: thegerm (---.sunsh2.vic.optusnet.com.au)
Date: September 28, 2012 01:38AM

G'day,

Thanks heaps for the two quick responses.
I have found the problem, I think. I was double clicking on a pure html file (sort of a menu) that has a link to my main html/php file. This works OK, but its fairly simple html. I thought that would be OK, but obviously its not because if, instead, I follow the path from using 'Localhost' in my browser, php gives me heaps of errors about not being able to connect to the database. This is because the database itself doesn't exist yet and I expected these errors.

Also, a bit of a hint from StevenMartin99 lead me to realise that my 'include' statements were not being executed, that's why I tried using localhost.


So, I think I'm OK now

Thanks again,
..Paul



Edited 1 time(s). Last edit at 09/28/2012 05:07AM by stevenmartin99.

Options: ReplyQuote


Sorry, only registered users may post in this forum.