+ Reply to Thread
Results 1 to 6 of 6
Like Tree2Likes
  • 2 Post By fomalhaut

Thread: Display all that would be secret while Mysql is broken

  1. #1
    fomalhaut is offline x10Hosting Member fomalhaut is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    South of France near Arles
    Posts
    91

    Display all that would be secret while Mysql is broken

    Hello.

    While the Mysql update, if I try to connect my website, I got a (normal) error.

    What must I change for not display secret things, like user, password ? Here is the message I have :
    <br />
    <b>Fatal error</b>: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user 'usr_ident'@'int.chopin.x10hosting.com' to database 'usr_dbName'' in /home/usr/public_html/repinc/DBase.inc:4
    Stack trace:
    #0 /home/usr/public_html/repinc/DBase.inc(4): PDO-&gt;__construct('mysql:host=loca...', 'usr_ident', 'password')
    #1 /home/usr/public_html/index.php(5): include('/home/usr/publi...')
    #2 {main}
    thrown in <b>/home/usr/public_html/repinc/DBase.inc</b> on line <b>4</b><br />
    (naturelly, I've masked the real user, password ecc. by usr, ident, dbName...)

    Thanks if you can help me.
    dinomirt96 and karimirt47 like this.

  2. #2
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: Display all that would be secret while Mysql is broken

    Quote Originally Posted by fomalhaut View Post
    Hello.

    While the Mysql update, if I try to connect my website, I got a (normal) error.

    What must I change for not display secret things, like user, password ? Here is the message I have :
    (naturelly, I've masked the real user, password ecc. by usr, ident, dbName...)

    Thanks if you can help me.
    So that is why you have to define the variables separately not in the connect statement like

    PHP Code:

    $username
    ="database_username";
    $password="password";
    $database="database_name";
    $databasehost "localhost";

    mysql_connect($databasehost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database"); 
    So even it shows the error line it shows only this
    mysql_connect($databsehost,$username,$password);
    Last edited by Gouri; 04-08-2010 at 04:51 AM.
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  3. #3
    fomalhaut is offline x10Hosting Member fomalhaut is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    South of France near Arles
    Posts
    91

    Re: Display all that would be secret while Mysql is broken

    That's so simple !!!

    I'll do that asap.

    Thank you very much Gsonline

  4. #4
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    Re: Display all that would be secret while Mysql is broken

    You know, I tried that, but when I tried that (using PDO) it still showed my information. So I just put under the catch statement a function that writes the error to a file and displays custom error text I.E. "Cannot connect to server."
    Last edited by as4s1n; 04-08-2010 at 01:35 PM.
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

  5. #5
    fomalhaut is offline x10Hosting Member fomalhaut is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    South of France near Arles
    Posts
    91

    Re: Display all that would be secret while Mysql is broken

    As4s1n : That's exactly what I've done too, because in fact, PDO translate the variables to their values.

    No problem.

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Display all that would be secret while Mysql is broken

    Catching the exception is the only way, but you can make it easier .

    PHP Code:
    class LocalDB extends PDO {
        static 
    $dbs = array();

        static function 
    connect($db='dflt') {
            if (! isset(
    self::$dbs[$db])) {
                try {
                    
    self::$dbs[$db] = new PDO("mysql:hostname=localhost;dbname=$db"'user''passwd');
                } catch (
    PDOException $exc) {
                    
    // erase frame w/ password from call trace.
                    
    throw new PDOException($exc->getMessage(), $exc->getCode(), $exc->getPrevious());
                }
                
    self::$dbs[$db]->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
            }
            return 
    self::$dbs[$db];
        }

    RAII support left as an exercise.
    Last edited by misson; 04-09-2010 at 07:51 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Broken MySQL databases
    By ntadej in forum Free Hosting
    Replies: 7
    Last Post: 10-27-2009, 11:37 AM
  2. Display image in MYSQL
    By acellec in forum Programming Help
    Replies: 27
    Last Post: 06-22-2009, 03:27 PM
  3. Replies: 7
    Last Post: 11-20-2008, 06:54 AM
  4. [Auction] Secret-isle.org & Secret-Isle.Org
    By Derek in forum The Marketplace
    Replies: 0
    Last Post: 10-10-2008, 10:41 PM
  5. mysql broken?
    By jdpalmer in forum Free Hosting
    Replies: 7
    Last Post: 10-19-2007, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers