Jump to content

Recommended Posts

Sorry about the undescriptive title. I couldn't think of the name of my problem.

I bought a MySpace friend train script, and I seem to be getting a problem.

[a href=\"http://www.mshangout.com/train/index.php\" target=\"_blank\"]http://www.mshangout.com/train/index.php[/a]

This is the error:

[code]Warning: main(pages/.php): failed to open stream: No such file or directory in /home2/meamruss/public_html/train/pages.php on line 11[/code]
This is line 11:
include "pages/" . $page . ".php";

Throughout the whole script files, there is no such variable $page. However, the index page has only the following content:
<meta http-equiv="refresh" content="0;url=pages.php?page=home">

I'm guessing that "home" is $page in this case. The header (Home Page | Join the Train | What is the Train?) links have this format:
<a class="link_whitetored" href="pages.php?page=faq">FAQ</a>

Obviously, it assumes that it should load what's after the = for $page. But why isn't it reading what's after this = sign? It's just giving me pages/.php.

Sorry if that was confusing.

Thanks in advance.
Link to comment
https://forums.phpfreaks.com/topic/6532-php-help-needed/
Share on other sites

The problem is that this is probably an old script and uses outdated techniques for managing $_GET variables.

There used to be a setting called register_globals which meant that if you send a variable through the URL (as page.php?variable_name=variable_value ) in page.php the $variable_name variable will already be automatically set. There was no need to get it from the $_GET array. In your case $page is the variable that the script expects to be automatically set.

This functionality has since been removed (for security reasons i think) so you have to set $page manually by extracting it from the $_GET array. Add:

[code]$page = $_GET['page'];[/code]

somewhere above the include line and it should work.
Link to comment
https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23689
Share on other sites

The problem with this method is that you are adding $_GET['page'] to the end of $page and then $_POST['page'] to the end of $page so if the variable $page already exists it may not come out how you expected. Your way is very simple and works, but you should keep this in mind in the event you run into a problem with this in the future.

[code]if ( $_SERVER['REQUEST_METHOD'] == "GET" ) $page = $_GET['page'];
if ( $_SERVER['REQUEST_METHOD'] == "POST" ) $page = $_POST['page'];[/code]

or

[code]if ( isset($_GET['page']) ) $page = $_GET['page'];
if ( isset($_POST['page']) ) $page = $_POST['page'];[/code]

Just some food for thought.
Link to comment
https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23731
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.