craigj1303 Posted September 10, 2010 Share Posted September 10, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/ Share on other sites More sharing options...
DavidAM Posted September 10, 2010 Share Posted September 10, 2010 It says the error was in the output_fns.php file. Did you leave the openning PHP tag ("<?php") out of the file; or use a short tag ("<?")? Short tags are not a good idea and are disabled on some servers. Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109444 Share on other sites More sharing options...
craigj1303 Posted September 10, 2010 Author Share Posted September 10, 2010 Hi David, Nope, all my pages begin with "<?php" as the opening tag. I tried deleting "output_fns.php" as a test out of curiousity and PHP then failed to parse the next included file "general_fns.php". Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109446 Share on other sites More sharing options...
DavidAM Posted September 10, 2010 Share Posted September 10, 2010 <<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? Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109461 Share on other sites More sharing options...
Rifts Posted September 10, 2010 Share Posted September 10, 2010 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109477 Share on other sites More sharing options...
wildteen88 Posted September 10, 2010 Share Posted September 10, 2010 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109502 Share on other sites More sharing options...
AParson Posted September 10, 2010 Share Posted September 10, 2010 unexpected T_STRING Hi, New here, just registered a moment ago... Now back on topic: I might be wrong (cause I'm not that good in PHP), but isn't "unexpected T_STRING" related to missing semicolon? Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109520 Share on other sites More sharing options...
craigj1303 Posted September 10, 2010 Author Share Posted September 10, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/213016-working-local-php-project-doesnt-function-on-web-server/#findComment-1109722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.