Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 16th, 2006, 09:44 PM
Authorized User
Join Date: Oct 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Nicholsen
Default Connect php to mysql

I want to connect to database from PHP to MySQL.
MySQL version is 4.1
If I compile the php code below:

$link_id = mysql_connect("localhost", "phpuser", "phppass");
$result = mysql_list_dbs($link_id);
$num_rows = mysql_num_rows($result);

while($db_data = mysql_fetch_row($result)) {
        echo $db_data[0]. "<BR>";
        $result2 = mysql_list_tables($db_data[0]);
        $num_rows2 = mysql_num_rows($result2);
        while($table_data = mysql_fetch_row($result2)) echo "--" . $table_data[0]. "<BR>";
        echo "==> $num_rows2 table(s) in " . $db_data[0] . "<P>";

The error occurred:
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in c:\inetpub\wwwroot\ch11\list_db.php on line 4

Warning: mysql_list_dbs(): supplied argument is not a valid MySQL-Link resource in c:\inetpub\wwwroot\ch11\list_db.php on line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ch11\list_db.php on line 6

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\ch11\list_db.php on line 8

What’s the problem! Is there any configuration on mysql after I install it! And How can I connent PHP to Microsoft SQL Server and Microsoft Access!
Can somebody give me the solution. Thank You

Old December 3rd, 2006, 02:34 AM
Registered User
Join Date: Dec 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

What version of PHP have you installed? You might consider PHP5 if using MySQL 4.1, or note that PHP4 (while it works) is considered an old client to MySQL 4.1 and above - see the following regarding a change in MySQL 4.1 for passwords: http://dev.mysql.com/doc/refman/5.0/en/old-client.html. You can resolve the "old client" issue be following the instructions outlines.

I'm assuming you're environment is Windows (and I'm comparing to my 5.1.6 PHP install) - to connect to MS-SQL, uncomment the line "extension=php_mssql.dll" in php.ini and restart IIS.

Regarding MS Access - I think there may be fancier ways, but the short and easy answer is to connect over ODBC. Here's an article that might help: http://www.phpfreaks.com/tutorials/61/0.php

Similar Threads
Thread Thread Starter Forum Replies Last Post
connect to mysql db from php 5 crmpicco PHP Databases 1 September 26th, 2007 05:14 PM
unable to connect PHP with Mysql bhavna MySQL 1 June 5th, 2007 07:52 PM
php connect to mySql parrot face PHP Databases 3 March 20th, 2007 03:42 AM
Connect php to mysql using dreamweaver Nicholsen MySQL 1 December 14th, 2006 07:26 AM
php connect to mysql p2ptolu Beginning PHP 2 February 24th, 2005 10:43 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.