faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL : Questions in search of an Answer

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 5 people (0%) answered Yes
Recently 0 of 5 people (0%) answered Yes

Entry

PHP doesn't send the username and password. -->MySQL Connection Failed:

Nov 19th, 2001 07:15
nano maus, idban secandri, Alius A, Onno Benschop,


U have to make sure that ur rights have been set right in the DB ur are 
trying to access, if u havent got the rights to acces it, then it u get 
exactly that same error msg, so if u know the password and login name 
is right, check overall user-access rights in the mysql-DB. Once uve 
edited that dont forget to restart mysql to initiate the changes.
otherwise try putting this code in an include file that u include at 
the top of ur php file:
function connect_to() {
  $mysqluser="<yourusernamehere>";      // username
  $mysqlpasswd="<yourpasswordhere>";    // password
  $mysqlhost="<yourmysqlserverhere>";      // name of computer MySQL is 
running
  $connID = @mysql_pconnect($mysqlhost, $mysqluser, $mysqlpasswd);
  if ($connID) {
       return $connID;
  }
  else {
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">
          <html><head>
          <title>Sorry, no connection ...</title>
          <body><p>Sorry, no connection to database ...</body>
          </html>\n";
    exit();                        // quit PHP interpreter
  }
}
u include it simply by putting:
include("<pathandnameofurincludefilehere>");
at the top of ur php pages and just call the function by using
$connID = connect_to(); 
works for me.... but if it still dont work... as i said check access 
rights!
hope it helped
nano