LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2019, 08:13 AM   #1
Mental-Octopus
Member
 
Registered: Sep 2018
Posts: 51

Rep: Reputation: Disabled
Getting PHP Parse error on Virtual Server


So I set up a virtual server on Ubuntu.
I uploaded a webpage in PHP which had no errors on the another Ubuntu server and on my local computer but for some reason shows a parse error on the Ubuntu Virtual server. So I'm wondering what the possibilities are for causing this error because I know for a fact the webpage has no errors unless different Ubuntu versions have different set of rules. Because the other OS I tested the webpage on is a slightly different linux distribution but same PHP version that is PHP7.
 
Old 08-23-2019, 08:45 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by Mental-Octopus View Post
So I set up a virtual server on Ubuntu.
I uploaded a webpage in PHP which had no errors on the another Ubuntu server and on my local computer but for some reason shows a parse error on the Ubuntu Virtual server. So I'm wondering what the possibilities are for causing this error because I know for a fact the webpage has no errors unless different Ubuntu versions have different set of rules. Because the other OS I tested the webpage on is a slightly different linux distribution but same PHP version that is PHP7.
Since you don't say what version of Ubuntu, or tell us anything about your script, or even the actual error, who knows?? Have you done any troubleshooting? Looked at the Apache and PHP log files? Checked the Apache versions?

Post your script along with the actual errors and some details, and we can try to help. But based on what you posted, there's nothing we can tell you.
 
2 members found this post helpful.
Old 08-23-2019, 09:55 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
There are many possibilities and all we basically know is there is something different between the two environments.

Something is not installed, installed incorrectly or configured incorrectly.
PHP is not configured correctly.
Apache or whatever web server is running is not configured correctly.

You will need to go back and reexamine the error and your script and hopefully it will become obvious why it isn't working as expected.
 
1 members found this post helpful.
Old 08-23-2019, 09:58 AM   #4
Mental-Octopus
Member
 
Registered: Sep 2018
Posts: 51

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
There are many possibilities and all we basically know is there is something different between the two environments.

Something is not installed, installed incorrectly or configured incorrectly.
PHP is not configured correctly.
Apache or whatever web server is running is not configured correctly.

You will need to go back and reexamine the error and your script and hopefully it will become obvious why it isn't working as expected.
Thanks a lot I will check now as to the version I'm using and php installation, I thought it could be something like that
just wanted to confirm.
PHP Parse Error: syntax error unexpected '}', expecting end of file in /var/www/file.php

I'm using the latest version of ubuntu which is 19.
 
Old 08-23-2019, 10:24 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by Mental-Octopus View Post
Thanks a lot I will check now as to the version I'm using and php installation, I thought it could be something like that
just wanted to confirm.
PHP Parse Error: syntax error unexpected '}', expecting end of file in /var/www/file.php

I'm using the latest version of ubuntu which is 19.
Well, seems simple enough; you have a typo in your code. How did you put this 'file.php' onto your new server??
 
Old 08-23-2019, 11:20 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Sometimes it is <? instead of <?php
Edit:
<? often works; <?php always works

Last edited by NevemTeve; 08-23-2019 at 12:32 PM.
 
1 members found this post helpful.
Old 08-23-2019, 12:15 PM   #7
Mental-Octopus
Member
 
Registered: Sep 2018
Posts: 51

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Well, seems simple enough; you have a typo in your code. How did you put this 'file.php' onto your new server??
Uploaded by sftp.
 
Old 08-23-2019, 12:28 PM   #8
Mental-Octopus
Member
 
Registered: Sep 2018
Posts: 51

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Sometimes it is <? instead of <?php
Really? I heard that it was the opposite.
 
Old 08-23-2019, 12:31 PM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by Mental-Octopus View Post
Really? I heard that it was the opposite.
Depends on version of PHP.
 
1 members found this post helpful.
Old 08-23-2019, 12:33 PM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
To be clear: <? often works (depends on a php.ini setting); <?php always works
 
2 members found this post helpful.
Old 08-23-2019, 12:36 PM   #11
Mental-Octopus
Member
 
Registered: Sep 2018
Posts: 51

Original Poster
Rep: Reputation: Disabled
Finally found the error now folks, thanks a lot yeah.
It was this demon here <? that I had to change to this <?php
Though I don't understand why some linux version treat the matter differently.
 
Old 08-23-2019, 01:05 PM   #12
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by Mental-Octopus View Post
I don't understand why some linux version treat the matter differently.
Not Linux versions; PHP versions.
And the answer to that is in the previous post.
 
2 members found this post helpful.
Old 08-23-2019, 01:48 PM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
It depends on distribution / version if the short open tag <? is enabled or disabled by default. Although I had read that with version 7.0 it was deprecated although from the posted PHP page it has not.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, unexpected '/' - can anyone see the error in this code? v@ny@ Programming 8 04-03-2010 04:07 PM
What's the meaning of "PHP Parse error: parse error, unexpected $ in..." frandalla Programming 23 03-04-2009 12:34 PM
PHP Error Parse error: parse error, unexpected $ in /home/content/S/k/i/SkinCare4U/h CowanServices Programming 2 12-09-2008 08:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration