0

I have the following php code:

<html><body>

    <?php include('scores.php?filename=scores/score.sco&scoresize=10&action=VIEW&viewtype=HTML'); ?>
</body>
</html>

You can see the result here: http://apps.facebook.com/krajecr/pokus2.php

As you can see, it tells me, that it doesn't exist. But if I use just the link: http://apps.facebook.com/krajecr/scores.php?filename=scores/score.sco&scoresize=10&action=VIEW&viewtype=HTML it works fine an I see exactly what I want to see. Where is the problem please?

Tom83B
  • 2,059
  • 4
  • 18
  • 28
  • If it wants you to make any permissions or it won't let you see it because you're not logged on, let me know, I'll try to do something with it – Tom83B Mar 10 '11 at 00:49
  • One often runs into this error, and to quickly troubleshoot it, follow these steps : http://stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 15:04

4 Answers4

2

As the error says, "scores.php?filename=scores/score.sco&scoresize=10&action=VIEW&viewtype=HTML" is not a file or directory. Just because you can enter querystring parameters ("?" and after) into your web browser does not mean that these are part of the filename. The filename is scores.php.

It looks like you want to go and make a request through a webserver rather than just opening a local file. Fortunately, include allows that natively too. However, you have to specify it:

<html>
  <body>
    <?php include('http://someserver.com/scores.php?filename=scores/score.sco&scoresize=10&action=VIEW&viewtype=HTML'); ?>
  </body>
</html>

Alternatively (and preferably, to save an HTTP request), if scores.php is on the same webserver, you can access it as a normal file but set the $_GET parameters beforehand, as these will survive through the include directive:

<html>
  <body>
    <?php
    $_GET = Array('filename' => 'scores/score.sco'); // add the others here too
    include('scores.php');
    ?>
  </body>
</html>

Hope that helps.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Thanks for the code. Others were probably trying to say the same, but I'm kinda new to php so I had no idea how they meant it. However I can't do it through web server, because it seems, that my server won't allow it. When I used the second code I got the following result: Warning: fclose(): supplied argument is not a valid stream resource in /3w/webz.cz/p/programming/facebook/scores.php on line 9 you can find it here http://apps.facebook.com/krajecr/pokus.php Does it actually have anything to do with the initial problem? Thanks – Tom83B Mar 10 '11 at 01:10
  • @Tom83B: The include succeeded, and scores.php is being included. However, you have an error with an `fclose` call in scores.php, as the message states. That would be a new question. – Lightness Races in Orbit Mar 10 '11 at 01:12
  • well, it is problem with fclose, but if the inclusion succeeded, I would see the table, because that's what I see when I use the direct link... – Tom83B Mar 10 '11 at 01:14
  • @Tom83B: That is a new question. The include *does* succeed, as the error message indicates that it is working on scores.php, and is about `fclose` which is not in the code in this question. – Lightness Races in Orbit Mar 10 '11 at 01:17
  • ok, I don't have many other possibilities than to believe you :-) – Tom83B Mar 10 '11 at 01:19
  • just in case you or someone else knew the answer - here's the question: http://stackoverflow.com/questions/5254413/inclusion-different-result-than-with-direct-link – Tom83B Mar 10 '11 at 01:26
  • I have started a troubleshooting checklist for this frequent error here : stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 15:04
0

The problem is that you've specified it as an access via the filesystem, when you actually need to have it access via the web server. Put in the full URL.

Better yet, convert the script to include into a function and then include and call it.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

As far as I know, you cannot use an include with parameters, it must be a file name. You can set the $_GET['var'] = 'value'; before your call to include for a way that does work.

RedSoxFan
  • 634
  • 3
  • 9
0

you cannot do an include with get values.

you can set all ur ness get values with

$_GET[..] = ...

and then do

include('scores.php')

Naftali
  • 144,921
  • 39
  • 244
  • 303