开发者

php failed to open stream - no such file or directory

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.face开发者_开发百科book.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?


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.


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.


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.


you cannot do an include with get values.

you can set all ur ness get values with

$_GET[..] = ...

and then do

include('scores.php')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜