meamrussian Posted April 4, 2006 Share Posted April 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/ Share on other sites More sharing options...
khendar Posted April 4, 2006 Share Posted April 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23689 Share on other sites More sharing options...
meamrussian Posted April 4, 2006 Author Share Posted April 4, 2006 Aha! That's the problem. It's using global variable. However, there is another part in the script that uses $post with POST instead of GET. How can I put them both in? I can't just put in $page = $_GET['page'];$page = $_POST['page'];How can I use both?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23692 Share on other sites More sharing options...
meamrussian Posted April 4, 2006 Author Share Posted April 4, 2006 I fixed it by doing this:$page.= $_GET['page'];$page.= $_POST['page'];Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23701 Share on other sites More sharing options...
khendar Posted April 4, 2006 Share Posted April 4, 2006 No Probs Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23712 Share on other sites More sharing options...
txmedic03 Posted April 4, 2006 Share Posted April 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23731 Share on other sites More sharing options...
Guest footballkid4 Posted April 4, 2006 Share Posted April 4, 2006 Or:[code]$page['GET'] = isset( $_GET['page'] ) ? $_GET['page'] : "";$page['POST'] = isset( $_POST['page'] ) ? $_POST['page'] : "";[/code]Then you can do things based on which one is set Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23746 Share on other sites More sharing options...
txmedic03 Posted April 4, 2006 Share Posted April 4, 2006 Now you have three examples. lol...Anyone else think of some more? Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23758 Share on other sites More sharing options...
shortj75 Posted April 4, 2006 Share Posted April 4, 2006 yes here is another example lol[code]if($_GET['page']==true){echo "your Code here";}if($_POST['page']==true){echo "your Code here";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6532-php-help-needed/#findComment-23877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.