Apache user doesn't seem to get parse error output.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Apache user doesn't seem to get parse error output.

Post by impulse() »

The PHP version I use at work doesn't give me any error information back when a PHP has syntax errors but my setup at home does. So I've wrote an online syntax checker that basically uploads a file to my box then runs 'php -l <uploadedFile>' and returns the error it receives.
The only problem is that it's only returning part of the error, which is the part I don't need. I would like it to include the line number and type of error, but it's only returning 'Errors parsing <file>'
I thought t his was due to the whole output not being stored in the variable but I ran some other system commands that have multiple line output and they display fine.

So at a guess it looks like the Apache user doesn't get the full error message, unless you can spot something in this code?

Code: Select all

<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

<?php

if($_POST) {

  $fName = $_FILES['uploadedfile']['name'];
  $tName = $_FILES['uploadedfile']['tmp_name'];
  $fSize = $_FILES['uploadedfile']['size'];

  $tPath = "/var/www/html/syntaxCheck/tmp/{$fName}";

  if(move_uploaded_file($tName, $tPath)) {
    system("php -l {$tPath}");
  }
  else
    echo "Didn't work";

}
Can anybody here offer any suggestions. I don't want a hoggy Java PHP editor with a syntax checker, which is why I've chose this route. I use a shell to do my editing so having to move files from server to desktop then load an editor and then syntax check it doesn't seem appealing.


Regards,
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That seems... pointless. The server at your job is probably set up to log errors instead of output them to the browser, and you could easily change that with ini_set() and error_reporting().
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I've tried

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', 1);
But without success.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Maybe they have other options in their php.ini set up that prevent you from seeing errors... I'd discuss it with the people who set it up. Also, you may just want to check the error logs.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Parse errors happen well before code in the script is run. You need to set the display_errors setting at the directory level or initialization file if possible. Otherwise, you need to talk to the server admin or set up your own local mirror of the codebase to test on your machine.
Post Reply