0

I have a file called pdo.php like this:

$pdo = new PDO('mysql:host=localhost;port=3306;dbname=yadayadadbname', 
   'yadadauser', 'yadayadapassword');
// See the "errors" folder for details...
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>

Which is used in the code by require_once "pdo.php";.

It's working fine, but I'm concerned about storing that pdo.php file on the public_html folder on the production server. Is there a safer way to store the pdo.php file or what's the better chmod permission for that file? Thanks in advance for any help.

Kmdd
  • 1
  • 1
    Does this answer your question? [How to secure database passwords in PHP?](https://stackoverflow.com/questions/97984/how-to-secure-database-passwords-in-php) – JoelCrypto May 29 '22 at 14:26
  • 1
    You can literally put that file anywhere as long as PHP can read it. One option (which I don’t recommend) is to update PHP’s search path pointing to a special folder. Another option which I would recommend is putting the file somewhere, and then using an absolute or relative path in your `require` statement. – Chris Haas May 29 '22 at 14:29
  • 1
    I also wrote an answer for a similar question: https://stackoverflow.com/a/24315768/20860 – Bill Karwin May 29 '22 at 15:32
  • What do you mean, "safer"? What is currently unsafe? – Your Common Sense May 29 '22 at 16:44

0 Answers0