Jump to content

"include('../db.php');" doesn't work


38175425
 Share

Go to solution Solved by cyberRobot,

Recommended Posts

1 hour ago, ginerjm said:

PS  You posted a line:

Posted 31 minutes ago

In the php file "create", you can see "include('../db.php');" in line 3.

You can see the file "db.php" in here

 

But I don't see the todo folder in there

If I put the file "db.php" in the folder "public_html", then the codes would work. But I want the file "db.php" to be in the folder "todolist_demo". 

db.png.e4b370a75cd0326656b93079f6f7b4f5.png

Link to comment
Share on other sites

14 minutes ago, ginerjm said:

That is not the same folder as you showed us earlier.

 

I quit.  You are not AT ALL helpful.

Sorry, I mean the codes would work if I moved the file "db.php" from the folder "todolist_demo" to "public_html".

Link to comment
Share on other sites

Whatever that means.  Perhaps you should work on your communication instead of your programming.  

Personally you should probably place sensitive php modules ABOVE your root folder where idle hackers have a bit harder time getting to.  Now (if you are showing is the right place) you seem to have this stuff inside your web root folder - not good.  And perhaps use an absolute path to avoid future confusion with your scripts.

Edited by ginerjm
Link to comment
Share on other sites

  • Solution

If I'm reading everything correct, the "create" script is under todolist_demo > public_html > todo. The "create" script isn't able to find your db.php because the following line only goes up one level.

include('../db.php');

Basically, you're telling "create" that db.php is in your public_html folder. You either need to use "../../db.php". Or I would actually recommend switching that line so it starts at the document root. I'm guessing "public_html" is your root folder. If that's the case, you could try the following:

include $_SERVER['DOCUMENT_ROOT'] . '/../db.php';

 

Edited by cyberRobot
Link to comment
Share on other sites

11 hours ago, cyberRobot said:

If I'm reading everything correct, the "create" script is under todolist_demo > public_html > todo. The "create" script isn't able to find your db.php because the following line only goes up one level.

include('../db.php');

Basically, you're telling "create" that db.php is in your public_html folder. You either need to use "../../db.php". Or I would actually recommend switching that line so it starts at the document root. I'm guessing "public_html" is your root folder. If that's the case, you could try the following:

include $_SERVER['DOCUMENT_ROOT'] . '/../db.php';

 

problem solved thank you!

Link to comment
Share on other sites

 

8 hours ago, ginerjm said:

And if you are really going to be a programmer you should enable the filename extensions in your windows install.  Makes it easier to tell one file from another when it has an .html or .php or a .js or a .inc on it.

Thanks for the tip!

Link to comment
Share on other sites

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.

 Share

×
×
  • 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.