Jump to content

PHP filename in sub-directory not allowed to be number w include


Niss3
Go to solution Solved by ginerjm,

Recommended Posts

Hello!

I am a beginner in PHP and made a simple quiz page. I named the quiz questions 1.php 2.php 3.php and so on to make coding simple when loading next question.

Now when I am done I wanted to "clean" things up. So I tried putting all the questions in a folder. That turned out to be a problem though.

When I use;

include(foldername\1.php);

The file is not loaded. It works fine if I put it back in the main directory.

After some error-searching I tried using letters instead of numbers, so I renamed 1.php to a.php and then suddenly it worked.

I really would like to keep the filenames as numbers, so if anyone here could help me figure out how to allow single digit number php files in a folder with the include command, please do!

Thank you very much!

Link to comment
Share on other sites

12 minutes ago, ginerjm said:

Basically it's telling you that there rules to filenaming.

What's wrong with naming them 'page1.php' and 'page2.php'?  Too hard to program?

I didn't think of that, thanks! I did a quick test but it appears I have made some other misstake now. I will try again tomorrow and return here with the sollution I came up with, but I will definitly try to add a prefix to the files!

Link to comment
Share on other sites

$filn=("f\aquick".$spelb);
include($filn.".php"); 

This is the sollution I came up with. Using include("path".$variable."filending") didnt work so I made some of it into a variable and it worked!

 

I have no idea what the double quote string thingy is. It did not accept "fraga" as filename either, so I guess it is complex when putting files in folders.

Link to comment
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.