0

I have a strange behavior with PHP system function. In this php script there are only 2 instructions (the rest being pure html):

<?php echo system('cgi-bin/gallery2/galleryheaderview.cgi'); ?>
<?php echo system('cgi-bin/gallery2/galleryview.cgi'); ?>

The first cgi just returns a single line as you can check here http://reboltutorial.com/cgi-bin/gallery2/galleryheaderview.cgi

It returns

My Gallery

But the whole php script returns My Gallery Twice:

My Gallery My Gallery

http://reboltutorial.com/gallery2.php

Is there a reason (I don't use My Gallery in second cgi script of course see http://reboltutorial.com/cgi-bin/gallery2/galleryview.cgi) and how to prevent this ?

Thanks.

2 Answers 2

4

Update: The system function will do two things. The first is, it will run a command and pass its output through to the browser and/or output buffer. The second is, it will return the last line of output. So when you're saying

echo system('/...');

You're saying "Hey system, output the results of this command" and then "Hey ehco, output whatever system returns". Removing the echo

system('/...');

will fix your problem.

A few other things to check

  1. Are you sure its galleryheaderview.cgi that's returning things twice? Comment out the include to make sure its actually the script that's echoing My Gallery twice

  2. Is your PHP page/program included/constructed in such a way that galleryheaderview.cgi is being called twice?

  3. Are you sure that calling the URL http://reboltutorial.com/cgi-bin/gallery2/galleryheaderview.cgi is calling the same command line as cgi-bin/gallery2/galleryheaderview.cgi?

If you've checked out the three items above, you'll need to drop into the source of galleryheaderview.cgi and see why its outputting the header twice.

Sign up to request clarification or add additional context in comments.

1 Comment

I have solved the problem by fusioning the two cgi script but it's not satisfactory your explanation now seems rational to me so I will try to remove the echo. Thanks.
1

Are you absolutely sure that nothing else is outputting the My Gallery before this line? You should try removing it, and see if it goes completely away or if there is still is one "My Gallery"

<?php echo system('cgi-bin/gallery2/galleryheaderview.cgi'); ?>

If this doesn't bring you any further, maybe you have included some php file twice?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.