Jump to content

Recommended Posts

<?php
if($page == ""){
include("main.php");
}
else{
include("$page.php");
}
?>


That is the script I'm using.

I had it hosted on my old host and it worked perfectly fine. I got a new host today and I just copied and pasted everything over... and I get this error..

Warning: main(main.php): failed to open stream: No such file or directory in /home/content/m/e/x/mexpresison/html/index.php on line 59

Warning: main(main.php): failed to open stream: No such file or directory in /home/content/m/e/x/mexpresison/html/index.php on line 59

Warning: main(): Failed opening 'main.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/content/m/e/x/mexpresison/html/index.php on line 59


Lol, this is probally a SIMPLE problem, but I'm dumb.

Thanks for the help!
Link to comment
https://forums.phpfreaks.com/topic/10629-the-easiest-php-script/
Share on other sites

Where are you defining $page? Chances are your new server has register_globals off (as it should)...... Just a guess, but try this...
[code]
if($_GET['page'] == "") {
    include("main.php");
} else{
    include($_[GET['page'].".php");
}
?>
[/code]
PS: Your code is also VERY insecure. You should check for the existence of these files before including them. As it is, anyone could quite easily hack your site.
Link to comment
https://forums.phpfreaks.com/topic/10629-the-easiest-php-script/#findComment-39643
Share on other sites

[!--quoteo(post=377765:date=May 28 2006, 02:20 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 28 2006, 02:20 AM) [snapback]377765[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Where are you defining $page? Chances are your new server has register_globals off (as it should)...... Just a guess, but try this...
[code]
if($_GET['page'] == "") {
    include("main.php");
} else{
    include($_[GET['page'].".php");
}
?>
[/code]
PS: Your code is also VERY insecure. You should check for the existence of these files before including them. As it is, anyone could quite easily hack your site.
[/quote]


Thank you SO much! The coding wasn't working but my friend help me mess with it and fix it so it'll work! I appreciate it so much!!! This error was making me so upset, lol. I feel better now.

Also, with this new coding, is my site a bit more secure or what?

Thanks!
Link to comment
https://forums.phpfreaks.com/topic/10629-the-easiest-php-script/#findComment-39644
Share on other sites

[!--quoteo(post=377766:date=May 28 2006, 01:44 AM:name=Chemmi)--][div class=\'quotetop\']QUOTE(Chemmi @ May 28 2006, 01:44 AM) [snapback]377766[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thank you SO much! The coding wasn't working but my friend help me mess with it and fix it so it'll work! I appreciate it so much!!! This error was making me so upset, lol. I feel better now.

Also, with this new coding, is my site a bit more secure or what?

Thanks!
[/quote]

Yes it is.
Link to comment
https://forums.phpfreaks.com/topic/10629-the-easiest-php-script/#findComment-39653
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.