Jump to content

Working local PHP project doesn't function on web server


craigj1303

Recommended Posts

Hi All

 

I have been working on a project in PHP for about three months. I have been happily working away with a WAMP server locally all that time. The problem arose today when I uploaded the project to a web server. I uploaded all the files by FTP and imported a mysql database on the new web server. When I went to view my home page I got the following error:

 

Parse error: syntax error, unexpected T_STRING in /home/priestbr/public_html/output_fns.php on line 1

 

My index page references an include to a page which stores my functions:

 

<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
include('priest_br_fns.php');

 

The priest_br_fns.php then includes a further 3 includes as below:

 

<?php
  include_once('db_fns.php');
  include_once('output_fns.php');
  include_once('general_fns.php');
?>

 

PHP seems to parse the db_fns.php page OK and fails at output_fns.php (as per the parse error msg). But here's the thing....during some investigation I deleted the contents of db_fns.php and pasted in the contents of output_fns.php and then the page got parsed OK!

 

Anyone have any idea why it's failing? Is it something to do with how I have the includes set up? I really need all the includes working obviously for the site to run.

 

For info my local server where the site works perfectly is set up as below:

 

PHP 5.2.6, MySQL 5.0.51a, Apache 2.2.8

 

The web server is set up like this:

 

PHP 5.2.1.14, MySQL 5.0.91, Apache 2.2.16.

 

Thanks in advance,

 

Craig

Link to comment
Share on other sites

<<Grasping at straws>> ...

 

Were the include files saved as unicode or utf-8? - although this normally presents as a different error (I think)

 

Is the project server a Linux server? Is it possible the files built on the WAMP (Windows) server have CR-LF line endings and the Linux server is choking on the CR? - Although FTP in ASCII mode should have converted these

 

Did you try crossing your fingers AND your toes the very first time you tried to load the page?

 

 

Link to comment
Share on other sites

<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
include('priest_br_fns.php');

 

I was under the impression that  session_start(); should be above anything so do this

<?php
session_start();
error_reporting(E_ALL ^ E_NOTICE);
include('priest_br_fns.php');

 

also you did post the code for the actual page that is giving you the error

output_fns.php

Link to comment
Share on other sites

<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
include('priest_br_fns.php');

 

I was under the impression that  session_start(); should be above anything so do this

<?php
session_start();
error_reporting(E_ALL ^ E_NOTICE);
include('priest_br_fns.php');

 

also you did post the code for the actual page that is giving you the error

output_fns.php

session_start() can be called on any line, provided no output has been sent to the browser.

 

@craigj1303: I think the issue is a file charset encoding issue. Make sue you are saving the file as ANSI or UTF-8 without the BOM.

Link to comment
Share on other sites

Well David & Wildteen,

 

It seems you were both on the right track with the charset thing. I always thought I just opened a text editor, typed my code, saved it and that was that. I didn't know there were different charsets to save under etc, but your comments got me looking in to it and I opened all my php files relating to this project in my text editor. At the foot of each page the text editor revealed different types for each file. Some said UNIX, some MAC and some DOS. The 2 includes that were failing were MAC ones. I cut the text and pasted in to a UNIX file, saved that and hey presto, it works now!

 

During this project I have been working on my apple imac, my windows XP laptop and my Windows XP laptop at work. I have been saving my work and transferring to flash drive and carrying between computers over time. I guess that is why some files have these different "charsets"? I don't know, but i've never seen any options available to save as a certain type of text. I thought it was just....well......text!

 

Anyway, thanks for putting me on the right track, I was up 'til 3am last night banging my head against the wall!]

 

Regards

 

Craig

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.