If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Can't connect php to msql.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-04, 18:22
tommytx tommytx is offline
Registered User
 
Join Date: Dec 2004
Posts: 2
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.
Reply With Quote
  #2 (permalink)  
Old 12-10-04, 03:32
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
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
Reply With Quote
  #3 (permalink)  
Old 12-12-04, 19:58
timvw timvw is offline
Registered User
 
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());
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On