connect to Mysql Server
| From: | Michael G. Tracey | Date: | Wed, 16 Jul 2003 22:53:10 +0000 |
| Subject: | connect to Mysql Server | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-20810@lists.php.net to get a copy of this message | ||
Code below comes straight out of the manual. I can connect using mysql client on other pc, and using
SQLyog. but Php will not connect. I can run php scripts with no problem otherwise.
Setup is: Win2k - sp3; php 4.3.2 ; Mysql 4.1; Apache 2.
This is the error I get:
;
Warning: mysql_connect(): Client does not support authentication protocol requested by server.
Consider upgrading MySQL client in C:\sokkit\site\mysql-conn.php on line 12
Could not connect
****************************
;<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php
/* Connecting, selecting database */
$link = mysql_connect("localhost", "michael", "access")
or die("Could not connect");
print "Connected successfully";
mysql_select_db("my_database") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM my_table";
$result = mysql_query($query) or die("Query failed");
/* Printing results in HTML */
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
?>
</body>
</html>
Michael G. Tracey
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!