| | |
help with mysql_connect();
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2004
Posts: 27
Reputation:
Solved Threads: 0
i can't connect to mysql. the error is
im using the script here in the php tutorial:
PHP Syntax (Toggle Plain Text)
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Documents and Settings\...
im using the script here in the php tutorial:
PHP Syntax (Toggle Plain Text)
$Host = "mysqllocation"; //location of mySQL on server $User = "username"; //my username $Pass = "mypass"; //my password $Name = "db"; //name of the database to be used $Table = "tabledb"; //name of the table within the database mysql_connect ($Host, $User, $Pass, $Name, $Table) or die ("unable to connect to database"); @mysql_select_db("$Name") or die ("unable to select DB"); $sqlquery = "SELECT * FROM $Table WHERE opinion = 'is horrible'"; $result = mysql_query($sqlquery); $number = mysql_num_rows($result);
•
•
Join Date: Feb 2005
Posts: 31
Reputation:
Solved Threads: 2
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());
?>
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());
?>
![]() |
Similar Threads
- Call to undefined function mysql_connect() (PHP)
- Warning: mysql_connect(): Access denied (PHP)
- Problems with PHP and the mysql_connect() command. (PHP)
- mysql_connect (PHP)
Other Threads in the PHP Forum
- Previous Thread: Help Me In Font Conversion
- Next Thread: Can't connect error on createuser
| Thread Tools | Search this Thread |
301 access apache api array beginner binary broken cakephp checkbox class clean cms code compression countingeverycharactersfromastring crack cron curl database date decode directory display dissertation dropdown dynamic echo email error fairness file files folder form forms function functions google href htaccess html httppost image include insert integration ip javascript joomla limit link login mail match md5 menu methods mlm multiple mysql newsletters oop pageing pagerank paypal pdf php problem protocol query radio random recursion remote script search secure server sessions simple sms soap source space spam sql syntax system table tutorial update upload url validator variable video votedown web youtube





