Page 1 of 1

Can't login to mysql trough php

Posted: Wed Nov 16, 2005 6:59 am
by JeePee
Hi, i have just started out learning php and mysql and i am following a video training session from 3dbuzz.com about connecting to the database trough a php script.

i have used the require command to call a sript where all the login information is stored and the the mysql_connect command mysql_connect ($db_host, $db_user, $db_password) or die "error connecting" to connect to the database. When i run all this it gives me the message error connecting, it does not give me any mysql or php errors so it's hard to figure out what's wrong.

Why do i not get any error messages? and what could be wrong? I am out of ideas.

Posted: Wed Nov 16, 2005 7:03 am
by Burrito
put this in your die() you should:

Code: Select all

mysql_connect("host","user","password")
  or die(mysql_error());
provide you with a more detailed description of your problem it will.

Posted: Wed Nov 16, 2005 7:03 am
by shiznatix

Code: Select all

mysql_connect ($db_host, $db_user, $db_password) or die(mysql_error());
then tell us what the error is. php wont auto give you a mysql error without you telling it to give it to you

edit: sigh, im always too slow

Posted: Thu Nov 17, 2005 7:33 am
by JeePee
k, done that. it sais my mysql client does not support some authentication mysql 5 needs and that i should concider upgrader my mysql client (using php4 now). I'll download php5 in a minute and then head home and try it out.
I'm just posting this here in case it isn't the solution because i don't have internet at home so i can't say if it's ok rightnow.

Posted: Thu Nov 17, 2005 5:54 pm
by AKA Panama Jack
JeePee wrote:k, done that. it sais my mysql client does not support some authentication mysql 5 needs and that i should concider upgrader my mysql client (using php4 now). I'll download php5 in a minute and then head home and try it out.
I'm just posting this here in case it isn't the solution because i don't have internet at home so i can't say if it's ok rightnow.
That's not a PHP problem.

What that is telling you is that the Mysql Client on your server cannot connect to the Mysql Server on the database server. This usually happens when the server and client software for Mysql are different.

Code: Select all

<?php
		 echo mysql_get_client_info();
?>
Create a little test program from the above to get the Mysql client version and then compare that to the version of the Mysql Server you are trying to connect. If they are different then there is your problem. You will need to upgrade the Mysql Client on the server PHP is running.

Posted: Fri Nov 18, 2005 8:39 am
by JeePee
“What that is telling you is that the Mysql Client on your server cannot connect to the Mysql Server on the database server. This usually happens when the server and client software for Mysql are different.”

What is the Mysql Client?, I thought it ment php. And what do you mean with “the Mysql Server on the database server”? Aren’t they both the same thing?

I am running the latest version of Apache, php and mysql now (was using php4 when I got the error). I don’t get the error anymore but it still doesn’t work.
I’ll fiddle with the test thing you gave me but I don’t quite get the picture of what you’re saying..

I am connecting locally by the way.

Posted: Fri Nov 18, 2005 9:03 am
by Frosty
I think he meant the server...
Anyways, it seems you have a weird issue. I can only suggest making sure that all of the server somponents are running. Also, make sure you have the right username and password. I am sorry if I come off making you sound dumb, I don't think you are, but that is all I can think of at the moment.

Also, http://us3.php.net/manual/en/ref.mysql.php, I would suggest reading that just to make sure you have the right code.

Posted: Fri Nov 18, 2005 1:25 pm
by AKA Panama Jack
Mysql has two different parts.

There is the Mysql Server which is what manages the Mysql Database. It is what really executes all of your SQL queries, monitors and manages the health of the database.

Then there is the Mysql Client which is how programs like PHP communicate with the Mysql Server. The Mysql Client is NOT a part of PHP. When you compile PHP with Mysql support you add the ability for PHP to communicate with the Mysql Client on your server and through the client communicate with the Mysql Server.

It is possible for the Mysql Client to be an old version while the Mysql Server is a newer version especially if you upgraded from a Mysql 3.xx version that came default with your linux install. This is why I posted that little snippet of code for checking your linux servers Mysql Client version.

If the Mysql Server is version 5 and Mysql Client is version 4 or 3 then you will not be able to connect to the Mysql Server. Make a small script and run that code I posted and find out the Mysql Client Version. I bet it is not the same as the server.

Posted: Sun Nov 20, 2005 4:16 am
by JeePee
I figured that yesterday when i started up the mysql client from the start menu instead of going in from the regular command prompt. Thanks for clearing it up.

The only problem i'm having now is figuring out where i can download an updated client, i tried fresh installs of mysql 4 and 5 with included client but aparantly they come with an outdated client.

Posted: Sun Nov 20, 2005 8:38 am
by AGISB
Could it be that your php was compiled with a older version of mysql and you only got the new version running?

Posted: Sun Nov 20, 2005 1:12 pm
by AKA Panama Jack
You go right to the source to download any of the files you need. http://www.mysql.com/

Posted: Mon Nov 21, 2005 5:15 am
by JeePee
I got it working by creating an account with the old_password command. It then uses the old password encription wich is compatible with the older client i have running.

About downloading the files i need; I do not know wich files i need, there is no download that sais "mysql client update" or "mysql client ver.blabla". And i don't see anything that as far as i can tell could be it.

I got everything working now, that's what's most important, though it still will be nice if i can tackle this issue.

Anyways thanks for the help so far.

Posted: Mon Nov 21, 2005 12:55 pm
by AKA Panama Jack
It's easy to find the versions... Click on the download link on the main mysql link I posted for you. This is the download link... http://dev.mysql.com/downloads/

You will see links for version 5 http://dev.mysql.com/downloads/mysql/5.0.html and version 4.1 http://dev.mysql.com/downloads/mysql/4.1.html and older versions http://downloads.mysql.com/archives.php. Click on one of those links. The older versions links gives a list of versions from 3.xx to 5.xx. Click on something like the 4.1 versions on the older versions page and you get a list of 4.1 versions. Click on the version you are using and then find what you need from the list of files.