Jump to content

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


38175425
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

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

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.