How to protect password for mysql_connect in php script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gbrendemuehl
    New Member
    • Jan 2007
    • 7

    How to protect password for mysql_connect in php script?

    I am adding some database driven functionality to my web site and will need a php script like to sample below to connect to the database. I have found some solutions for protecting the password by storing it in a file outside the web directory. But my web-hosting is a shared linux account @ Go Daddy and I don't appear to have access outside the root. Any suggestions for how I can secure the password?

    Thanks
    Gary

    <?php
    $link = mysql_connect(' localhost', 'mysql_user', 'mysql_password ');
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';.
    mysql_close($li nk);
    ?>
  • assimlation
    New Member
    • Nov 2007
    • 9

    #2
    you can't go to the directory below public_html ?

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      I don't think you should worry about it really..

      Just save it in a directory 'library'

      I dont see how someone would get access to it..

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        The end users (web browser) will get the generated HTML out put only. They can't see the source codes. No matter about, inside or out side public root. anyhow the hosting company can read them all. If it is a problem for you, there are so many Third party tools to encode your php scripts. but sure the execution of the php engine will slow down on this process. but still the hosting company guys can access the database. no way to prevent it. but if you want to prevent, the only way is, use your own Server to host the Application.

        Comment

        Working...