Jump to content

[SOLVED] Require error.


timecatcher

Recommended Posts

Hey everyone im trying to create a new page and to do so I want to require the connect to database file so that everything can connect to it. However when I run it I get this error:

 

Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2

 

Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2

 

Fatal error: require() [function.require]: Failed opening required 'includes/connect.inc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/timecat/public_html/games/holgame.php on line 2

 

Which I don't understand considering I've included that same file before in all my other files.

 

Help needed thanks.

 

Timecatcher.

Link to comment
Share on other sites

Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2

 

Warning: require(includes/connect.inc.php) [function.require]: failed to open stream: No such file or directory in /home/timecat/public_html/games/holgame.php on line 2

 

I recommend to use the .php extension as some servers don't see with good eyes the .inc one, it will do exactly the same ;), it will look like: connect.php

 

I personally always use "include" instead of "require" and always works fine to me :)

this is an example

include "includes/connect.php";

Link to comment
Share on other sites

The error message is not lying. It is telling you what php found when it tried to execute your code - require(includes/connect.inc.php) No such file or directory. Either the file or directory does not exist relative to the main script that is being executed.

 

Now to the other posts made -

 

You would want to use an absolute file system path, not a link/url, because an include/require using a URL will not actually include the code into the current script.

 

The file name being used, according to the error message, is connect.inc.php, not connect.inc and the actual file name does not matter except if you use a file name not ending in .php, someone can browse to your file and see the php code in it, so if you are using .inc, don't put anything like database usenames or passwords in your file.

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.