Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to MySQL

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi,

I am trying to connect PHP 4.3.11, to MySQL 4.1 using the mysql_connect function. When I run this function (that i've used in the past on other systems without problem) I get an error saying something along the lines of "failed to connect, consider upgrading to the MySQL client version"

Does anyone know what i am doing wrong?

i basically have $conn = mysql_connect(details here);

and this fails

TIA

Tony
 
Do you have mysqli functions compiled? They are optimized for MySQL 4.1.3 servers - that's why you get the message.
There's something different in the password hashing algorithm that breaks binary compatibility.
 
I've got the windows (x86) installer, and let it do what it needs to do from the installer. I can connect to it through a command promot but when i try to get in via php it errors with the message above.

How can i tell if i have the compiled functions?
 
You can either:
-> try to connect using mysqli_connect (it may give an error message, then you'll know it is not enabled)
-> read the output from phpinfo() which tells you what is compiled.
 

Hi me again, I have finally got around to testing this, and found that it doesn't work, as I am using PHP 4.3.11, and apparently mysqli_connect is a php 5 function!

The error message I am getting is: "failed to connect to database as the requested authentication type is not supported consider upgrading to the client version"

I have tried the full install of the db server instead of the cut down version or whatever they call it and that doesn't work

Any ideas?

Tony
 
try something like this
Code:
<?
$dbserver="serveraddresshere";
$dbname="databasenamehere";
$dbuser="username";
$dbpass="password";

mysql_connect($dbserver,$dbuser,$dbpass);
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM tblname");

while ($row = mysql_fetch_array($result)) {
   echo "ID=".$row['fieldname']."<br>"; 
}

mysql_close();
?>
 
That is pretty much what I have got and it fails on the mysql_connect line, with the error mentioned above.

Tony
 
You have removed one .so too many. When it says that the function is undefined it means the module is missing.
Re-enable mysql in the php.ini and let us know if the same errors as before come up.
 
Sorry for the delay in between posting but this is just a little side project that isn't really my main focus.

As far as I know I haven't disabled mysql from the php.ini file. I hadn't even opened it until last night. All I have done is download the installer for php4.3.11 and the installer for mysql 4.1 and run them both. php is running and it allows me to do things, but php will just not connect to mysql. they are both on the same machine, and both are running. I can connect to mysql using the command line, but not from within php. kinda doing my nut in now!

TIA

Tony
 
PHP has to have the MySQL client library enabled. You do that through the php.ini
When you look at the output from phpinfo() you will see that there is no section for mysql (i.e. the client library) unless it is activated.
Since you have MySQL 4.1 (>4.1.3?) you should actually use the mysqli extensions.

Connecting to MySQL on the command line just means that the command line client code is installed on your system. It does not speak to the PHP installation at all.
 
Looking at the phpinfo() information there is a section for mysql, it talks about things like mysql.allow_persistant and other items like that.
 
What is the client version you have listed in there?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top