Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    3

    Unanswered: Can't connect php to msql.

    Can't connect php to msql.
    ********************
    I have installed a new issue of mysql 4.1 and am able to build and control a database via the cmd line. However I can't connect using php. My system is windows XP.
    My php commands require a pw and user name and I don't have a user name. I tried to connect to the root with php and could not. Below is the results and the php program I used. Any advice you could provide to this lost soul would be greatly appreciated.

    Message when trying to connect to apache with mysqltest.php
    ************************************************** *********

    Using no password for root.
    ***************************
    Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO) in C:\Program Files\Apache Group\Apache2\htdocs\mysqltest.php on line 7
    Sorry - unable to connect to MySQL

    Using the password for the root.
    ********************************
    Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Program Files\Apache Group\Apache2\htdocs\mysqltest.php on line 7
    Sorry - unable to connect to MySQL


    The below is the progmam I used.
    ********************************
    <?php
    $connection = mysql_connect ( "localhost", "root", "") or die ( "Sorry - unable to connect to MySQL" );
    echo( "Congratulations - you connected to MySQL" );
    ?>


    I have since gone into the root and granted full privileges to tommytx@localhost with password of tcx123.

    Now I can log onto the root with user tommytx and pw tcx123, however the problem continues that even though I use the user name and password, I can' connect to the data base via php.

    See the php program above.


    How do I get a user name to use with my password.
    I can get in at the cmd line using root and the pw but not with php.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    At a guess i'd try
    $connection = mysql_connect ( "localhost", "tommytx", "tcx123") or die ( "Sorry - unable to connect to MySQL" );

    can't be sure am away from PHP/MYSQL at present

  3. #3
    Join Date
    Nov 2004
    Location
    Melsbroek, Belgium
    Posts
    4
    php and mysql4.1 will require you to use new mysqli modules....
    http://www.php.net/mysqli

    thus

    $link = mysqli_connect('localhost', 'user', 'password', 'database') or die(mysqli_error());

Posting Permissions

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