944,181 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3669
  • PHP RSS
Feb 22nd, 2005
0

help with mysql_connect();

Expand Post »
i can't connect to mysql. the error is

PHP Syntax (Toggle Plain Text)
  1. Warning: mysql_connect(): Client does not support authentication protocol
  2. requested by server; consider upgrading MySQL client in
  3. C:\Documents and Settings\...

im using the script here in the php tutorial:

PHP Syntax (Toggle Plain Text)
  1. $Host = "mysqllocation"; //location of mySQL on server
  2. $User = "username"; //my username
  3. $Pass = "mypass"; //my password
  4. $Name = "db"; //name of the database to be used
  5. $Table = "tabledb"; //name of the table within the database
  6.  
  7. mysql_connect ($Host, $User, $Pass, $Name, $Table) or die
  8. ("unable to connect to database");
  9. @mysql_select_db("$Name") or die ("unable to select DB");
  10. $sqlquery = "SELECT * FROM $Table WHERE opinion = 'is horrible'";
  11. $result = mysql_query($sqlquery);
  12. $number = mysql_num_rows($result);
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
odee is offline Offline
27 posts
since Dec 2004
Feb 22nd, 2005
0

Re: help with mysql_connect();

IMHO, definitely upgrade MySQL if you can (depends on data migration basically). Just remember the later the version the more stable and feature rich the release. One other thing about connecting to MySQL or any other SQL server for that matter. However if your data set is small or reproducible then by all means proceed with the upgrade to the latest "stable" release.

Now back to your MySQL connect issue. Since the connect operation is your authentication into the DBMS it should be treated as an atomic operation. That is, pass or fail. Similarly the select is critical unless somehow your app can switch to a different DB which is highly unlikely. So.... here is an example you can customize that uses the die() function. From a networking perspective - MAKE SURE YOU CAN USE MySQL Query or MySQL Administrator with the user name, password, and DB so that you can prove the context. If it fails then you must GRANT access most likely.


<?php
define("DB_USER", "dbuser");
define("DB_PASSWORD", "dbuser99");
define("DB_HOST", "192.168.1.220");
define("DB_NAME", "test");

// Connect to the MySQL server
$db_connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or
die('Could not connect to MySQL: ' . mysql_error());

// Select the database
mysql_select_db(DB_NAME) or die('Could not select the database: ' . mysql_error());
?>
Reputation Points: 10
Solved Threads: 3
Light Poster
mcldev is offline Offline
31 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Help Me In Font Conversion
Next Thread in PHP Forum Timeline: Can't connect error on createuser





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC