Search code examples
phppdoconnectionrequire-once

Why does the function require_once prevent my code from working


At the top of my code I have the following

require_once 'PSBE_LOGIN';

where PSBE_LOGIN has all the information to access my database(I'm using a PDO connection). However, my code does not work but when I take it out, my code works perfectly. Any thoughts on why this is? I need the file there so I can collect information from my database.


Solution

  • Require (as opposed to include) will halt the execution of a script on failure. For example, if the specified file is not found.

    Thus your code can be fixed by ensuring the file exists and in the correct directory.