SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Nov 2000
    Location
    Chico, Ca
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Connecting to MySql

    I've done this before.. but from some reason I can't connect to MySql sucessfully

    Here is what I have:
    PHP Code:
     
     <?php
     error_reporting  
    (E_ERROR E_WARNING E_PARSE);
     
     
    $dbhost "localhost";
     
    $dbuser "root";
     
    $dbpasswd "IceCream";
     
    $dbname "shields";
     
     
     
    /*Connect to the database*/
     
    if(!$db = @mysql_connect("$dbhost""$dbuser""$dbpasswd"))
         die(
    'Could not connect to database');
     if(!@
    mysql_select_db("$dbname",$db))
         die(
    'Could not connect to database $dbname');
     
    ?>
    Is there a way to get a more specific error?

    What are some common problems when connecting from PHP to MYSQL

    I gave root access to the DB in question. The pw, username and DBname are correct.

    Any Idea's

    Chuck
    "Happiness doesn't find you, you find happiness" -- Unknown
    www.chuckknows.com

  2. #2
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this

    PHP Code:
       $dbhost 'localhost';
       
    $dbuser 'root';
       
    $dbpasswd 'IceCream';
       
    $dbname 'shields';
       
       
    /*Connect to the database*/
     
    $db = @mysql_connect($dbhost$dbuser$dbpasswd) or die ('Could not connect to server ' $dbhost ' due to ' mysql_error());
       
    mysql_select_db($dbname$db) or die ('Could not connect to database ' $dbname ' due to ' mysql_error()); 

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2000
    Location
    Chico, Ca
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swdev
    try this

    PHP Code:
        $dbhost 'localhost';
        
    $dbuser 'root';
        
    $dbpasswd 'IceCream';
        
    $dbname 'shields';
        
        
    /*Connect to the database*/
     
    $db = @mysql_connect($dbhost$dbuser$dbpasswd) or die ('Could not connect to server ' $dbhost ' due to ' mysql_error());
        
    mysql_select_db($dbname$db) or die ('Could not connect to database ' $dbname ' due to ' mysql_error()); 
    Thanks for the code. It worked great!

    With that said here is what I got...

    Code:
     Could not connect to server 127.0.0.1 due to Client does not support authentication protocol requested by server; consider upgrading MySQL client
    "Happiness doesn't find you, you find happiness" -- Unknown
    www.chuckknows.com

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2000
    Location
    Chico, Ca
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is what I found from MySql on the issue: http://dev.mysql.com/doc/mysql/en/old-client.html
    "Happiness doesn't find you, you find happiness" -- Unknown
    www.chuckknows.com

  5. #5
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My pleasure


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
  •