Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL password in PHP code

Status
Not open for further replies.

asfaw

Programmer
Jun 28, 2004
36
CA
I am not sure using md5 is correct in the code below:

Code:
        <?php
        $Host ="localhost";
        $User = "root";
        $Password =md5("secretl");
        $DBName="NewDatabase";
        $TableName="Feedback";

        $Link = mysql_connect($Host, $User, $Password)
            or die("Couldn't make connection: " . mysql_error());   //on failiure, post error message
          
        if($db = mysql_select_db($DBName, $Link))
        {
        print "connected to NewDatabase";
        }
        else
        {
          die("Couldn't select database:" . mysql_error());
          }
        ?>



The error message is as follows:
Couldn't make connection: Client does not support authentication protocol requested by server; consider upgrading MySQL client.

Asfaw
 
echo out $Password, and see what you get...also make sure that the mysql account password has been md5'd to match.

Bastien

Cat, the other other white meat
 
I am getting the same error. When I created the user account I used the MySQL client software and this is the command used to set the passoword:

mysql> SET PASSWORD FOR 'some_user'@'some_host' = PASSWORD('mypass');

I can log-in into MySQL using the MySQL client software by:

bin>mysql -u some_user -p

when I am prompted to enter the password I type the password it it turns to *******.

My question is how to log-in to MySQL using PHP?

Thank you for your help.

Asfaw
 
what version of mysql?

Bastien

Cat, the other other white meat
 
I am using MySQL 4.1.3B.

May be I have not make my question clear.

How did I set-up the user password for MySQL?
I used the MySQL client software using DOS prompt:
bin/mysql>update user set password=password('secretl') where user='root';

I can connect to mysql using the user root and the encrypted password secretl.

How do I connect to MySQL using PHP using the following code:

<?php
$Host ="localhost";
$User = "root";
$Password ="";
$DBName="winestore";

$Link = mysql_connect($Host, $User, $Password)
or die("Couldn't make connection: " . mysql_error()); //on failiure, post error message

if($db = mysql_select_db($DBName, $Link))
{
print "connected to winestore";
}
else
{
die("Couldn't select database:" . mysql_error());
}
?>

I am getting access denied error message.

Please help.

Asfaw
 

You're really making this much more complicated than it is.

Do: mysql_connect('localhost', 'root', 'secretl');

 
I am sorry. I am trying to make it simple. I have done some reseach and it may be the version of PHP and MySQL I am using. I am using PHP5 with MySQL 4.1.3b.

Thank you very much for you help.

Asfaw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top