Issues on eclipse generated php files uploaded through ftp - php

I have uploaded my PHP project created using Eclipse-PDT to the siteground server.
After completing the upload, i tried to run the php pages and it throws an error saying "Expected End of statement".
Then i logged in to the CPANEL and found that all the line breaks are removed from the script. since i have used "single line comments" in my php script ,its throwing error(next line will also append to the previous line)
can anybody help to solve this issue? i have a lot of php pages ,so its not possible to remove all single line comments from all the pages.

Maybe its caused by different file encoding?
Check which format is used in your editor.

Related

XML Parsing Error: xml processing instruction not at start of external entity

I have a vBulletin 3.8 forum.
When we click Edit button of any post (so the Quick Edit form should displayed), I get this error on the browser's console:
XML Parsing Error: xml processing instruction not at start of external entity
Location: http://www.xxxxx.xx/ajax.php?do=quickedit&p=438
Row number 2, Column 1:
... the Quick Edit form is not appearing the the progress bar displayed permanently.
I have try to disable hooks/ plugins, but the problem still appears.
I have this row on config.php: ini_set("display_errors", false); so I don't think it is a fatal error/ warning by PHP which brokes the xml normal syntax.
I have informed that this appear starts after the move of the site to another server. Does it say something to you?
Any general idea about this error?
EDIT:
Well, I found the reason of this issue, but I don't know how to fix it. Exact the same site on a localhost testing board works perfectly, but on the live server ANY html page/ ajax call etc, has a useless empty line as line #1.
For normal html pages, there is no reason for the browser to return an error, but when we're talking about an ajax call, this empty line at the top of the response, breaks the xml parsing from the browser. So it seems it is a server/ PHP/ Apache setting that applies this empty line. Any idea how to fix it? https://imgur.com/a/4neb0
It might be late for you but any new comers with php/nginx/apache can get an understanding of why.
Answer is simple: When moving the code, you might not be using git/rsync/scp but let me guess, you used zip (and probably Windows/Linux involved).
How to discover it was a two-day journey with many things tried:
We have the same error, we were also moving our servers. We tried:
We thought the server software version was a problem.
We thought the cloud provider OS image was a problem.
We used docker to avoid these problems, but the empty line problem persists.
We thought the code ?> ending was a problem, I went through all of them. But it wasn't.
I finally asked my colleague: How did you get the code? From Git? He said he downloaded from ZIP and then uploaded to server.
I removed code on the server (which extracted from a zip) and used git to download a fresh copy from our github.
Magic, problem solved. The empty line gone.
So I think the problem is with the zipping progress might have changed some file empty lines. Always use git.

Uploading an Article to Joomla 3.6 using a PHP Script

For the past years we have used a local application that uploads articles to our Joomla homepage (Using a PHP Script). After the latest update to Joomla 3.6 (Used to be 3.5) that application no longer works. The following error occurs:
Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/var/www/DOMAIN/htdocs/FOLDER/execute.php" at line 1.
There used to be an "application.php" file inside ./htdocs/FOLDER/administrator/includes/ and after the update the file disappeared. It looks like the script can't create an instance of the application. I have already tried to repair the Database using the Back End option, but that didn't solve the problem.
Update: The above error occurs at:
$mainframe = JFactory::getApplication('administrator');
Help is much appreciated!
Some text is being output by "/var/www/DOMAIN/htdocs/FOLDER/execute.php", probably white space at line one. Check nothing is output before sending any headers.
Not a great resolution but you could also clean the output buffer before the header fn. Have a read of ob_clean()

PHP error after new install of xampp

I was recently switched computers at work, and am trying to get all my projects up and running again. I am working on testing some php/html/javascript pages for a website using a local xampp server. I had everything working properly on the only computer, but when I try to load the pages now I get the following error:
Uncaught SyntaxError: Unexpected token <
I have tried a php-only test page, so I know the sever is capable of parsing php.
I also know it is not the short tag issue, as all of the php code is wrapped in
<?php...?>
Are there any other configuration settings that would be causing this issue?
The error message doesn't look like a PHP error. Check this discussion maybe you can find the solution there.
It seems the error is reported by Google Chrome when it expects to parse a .js file and it finds HTML (or PHP?) instead.
I think it is a JavaScript error, you should check your js code, not php.
The following reasons might cause this error:
href attribute value "javascript: void ()", no brackets add "0"
Button // error
Button // correct
Non-compliant JSON string
etc.

Make latex fonts available for all users for a php compilation

I'm having problems with compiling a latex document using PHP shell_exec. I thought I had solved the problem, but alas I did not.
I have asked somthing similar before:
Compiling a latex document from PHP
And this answer led to me believe that the problem is simply the fact that the www-data user that executes the php scripts doesn't have access to the right font file.
It seemed that this page had the solution:
How can I get PHP to compile a LaTeX document if it (www-data) can't get access to the required packages?
What I did is log as root, execute the command and it threw a bunch of text but no error was reported. Then I tried my webpage again, and the font not found error was still there.
Every time I try a compilation I get the error:
<inti.pdf, id=1, 533.995pt x 298.11375pt> <use inti.pdf> [1{/var/lib/texmf/font
s/map/pdftex/updmap/pdftex.map} <./inti.pdf>]
(./report.aux) )
!pdfTeX error: pdflatex (file ecrm1095): Font ecrm1095 at 600 not found
Don't know if the first part of the message is important or not so I copied it anyways (inti.pdf is a picture in the report.tex).
The missingfont.log file has this line:
mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 ecrm1095
How can I make the font be seen by the system. Maybe setting a environment variable? Or a Sudo command so that the font will permanently be seen by all users?
Ok, so I found a workaround/another clue to the problem. I'm only posting it here so it might help anyone else.
Firs of all, I was wrong. This is not a user permission issue. I changed my server username to my own and I still had the font not found problem.
However I was able to isolate the problem to one of the latex lines.
In particualar it started working correctly as soon as I commented:
\usepackage[T1]{fontenc}
The line was inherited from a header I always use, but was not fundamental to the document and hence this managed to solve it.

PHP "require_once" says it can't find a file in the directory

I'm debugging some PHP code written by an outsourcing company (I'm not a PHP guy at all but know the basics; we have an offshore team of PHP developers working for us on this project) that's not working; the code is supposed to be called every 30 minutes by a cron job but its not firing. I tried to run the PHP script via the command line to test if it's working, but it's giving me the following (anonymized) errror:
PHP Fatal error: require_once(): Failed opening required '/myapp/_lib/_classes/MySql.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/myapp/_lib/_base/common.inc.php on line 6
However, the file /var/www/html/myapp/_lib/_classes/MySql.php exists under the proper directory. I'm missing something simple, I'm sure, but like I said I know really nothing beyond the bare basics of PHP and I really need to get this service up and running.
EDIT: The code is using the __autoload() function with all classes in /_lib/_classes
if you start a file name with a slash, it means it's an absolute path. try instead:
require_once('/var/www/html/myapp/_lib/_classes/MySql.php');
Case sensitivity maybe? I've had that problem before.
I'm guessing it's a permissions issue - make sure both your account (for testing purposes) and whatever account cron is going to run your script under (quite possibly yours, but maybe a different one) have read privileges on the file.
Also: the path for the include says /myapp/_lib/_classes/MySql.php, whereas it exists in /var/www/html/myapp/_lib/_classes/MySql.php. Can you change the include to reference the full path?
As said, casing and in addition the correct permissions to access that file are needed.

Categories