Can't login to mysql trough php
Moderator: General Moderators
Can't login to mysql trough php
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.
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.
put this in your die() you should:
provide you with a more detailed description of your problem it will.
Code: Select all
mysql_connect("host","user","password")
or die(mysql_error());- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Code: Select all
mysql_connect ($db_host, $db_user, $db_password) or die(mysql_error());edit: sigh, im always too slow
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.
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.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
That's not a PHP problem.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.
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();
?>“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.
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.
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.
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.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
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.
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.
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.
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.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
You go right to the source to download any of the files you need. http://www.mysql.com/
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.
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.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
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.
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.