SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot fredep57's Avatar
    Join Date
    Aug 2009
    Location
    Pacific Northwest
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DB script hacked or??

    I hope this is in the right place, and if not please move it to the correct area.

    OK, I have a file that is supposed to hook to my DB. The file is below:
    PHP Code:
    <?PHP

    function get_db_connection()
    {
        
    // Connection Variables
        
    $hostname="localhost";
        
    $mysql_login="someuser";
        
    $mysql_password="someuser_pw";
        
    $database='main';
        
        
        try
        {
            
    // Connect to the database server
            
    $pdo = new PDO("mysql:dbname=$database; host=$hostname"$mysql_login$mysql_password);
            
    $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); 
            
    $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); 
                    
            if ( 
    $pdo )
            {
                
    //echo 'connected';
                
    return ($pdo);
            }
            else
            {
                echo 
    'DB error';
                
            }
        }
        
        catch (
    PDOException $e) {
        echo 
    'Connection failed: ' $e->getMessage();
        }
    }
    ?>
    However, on the live site, when I try to use it in the php file, I get an error log entry that says:
    [24-Feb-2014 08:24:43 America/Denver] PHP Warning: mysql_query(): Access denied for user 'ryanholman'@'localhost' (using password: NO) in SponsorsPDOnonAlphaAdv.php on line 47
    SponsorsPDOnonAlphaAdv.php is the calling php script and does not pass any information about the DB, just gets the return $pdo if the connection is done appropriately.

    So, have I been hacked? Or why is it trying to use the "ryanholman@localhost" to log on to the DB? I don't know a ryan holman.

    Thanks for any help.
    E

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    If you do not have ryanholman@localhost in your script is there another version of the database connect on the server - did you use an example from ryan holman to write your code?

    Try echoing the connection variables in SponsorsPDOnonAlphaAdv.php file to see what it thinks it is using.

    mysql_query(): in the error looks a bit strange as you are using pdo - did you use to use MySQL and have changed over to pdo and not changed the include value?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •