Page 1 of 1

MySql login and authentication help

Posted: Thu Dec 11, 2003 3:57 am
by dbudde
Ok, I am having a problem with authenticating to MySql server in this manner. What I was trying to do was contact the MySql "rights" tables to check and make sure the current user is part of the MySql database system. When I run the following code I am always receiving back a rowcount of zero indicating the username and password I entered does not exit, but it in fact does. In real life my username and passwords are variables. If anyone could help me to know what I am doing wrong or if there is a better way I would appreciate it.

Code: Select all

mysql_select_db('mysql', $link) or die ('Cant connect to DB mysql : ' . mysql_error());

$query = "SELECT * FROM user WHERE user = 'my_username' AND password = 'my_password'"; 

$result = mysql_query($query, $link) or die(mysql_error());

$rowcount = mysql_num_rows($result);

Re: MySql login and authentication help

Posted: Thu Dec 11, 2003 4:03 am
by JayBird
dbudde wrote:Ok, I am having a problem with authenticating to MySql server in this manner. What I was trying to do was contact the MySql "rights" tables...
But you are selecting from the 'user' table!?

Mark

Re: MySql login and authentication help

Posted: Thu Dec 11, 2003 5:15 am
by Weirdan
Bech100 wrote:But you are selecting from the 'user' table!?
database `mysql` has no `rights` table. But it has `user` table where global access rights(permissions?) are stored.

Re: MySql login and authentication help

Posted: Thu Dec 11, 2003 5:20 am
by JayBird
Weirdan wrote:database `mysql` has no `rights` table. But it has `user` table where global access rights(permissions?) are stored.
are you telling or asking :)

Posted: Thu Dec 11, 2003 7:13 am
by Weirdan
I wasn't sure which word to use ;)

ok, i will try to clarify

Posted: Thu Dec 11, 2003 9:04 am
by dbudde
Ok, I will try to clarify. The USER table in MYSQL db is part of all the tables that sets permissions for users of the MYSQL db. So, what I need is some way to check that the person attempting to log into the website I am working on actually exists in the user table. So, I need either some alternate manner of authentication to the MYSQL db or I need to get what I am attemting to do working using variables for the 'username' and 'password' where the example I gave simply shows hard coded username and password.

Posted: Thu Dec 11, 2003 2:25 pm
by AnsonM
So are you trying to make sure that the username does not exist in the database before registering them??

If so, please tell us

I believe what you are saying is correct.

Posted: Thu Dec 11, 2003 3:55 pm
by dbudde
I am trying to see if the user exists in the MySql permissions tables to see if they are infact an authorized user of if they are not an authorized user in the way you said that.

I am not registering the users, I am trying to find out if they are already a valid user in the MySql before allowing them to continue into the website.

bad grammar

Posted: Thu Dec 11, 2003 3:59 pm
by dbudde
Boy sorry about the bad grammar, I was in a hurry. Anyway, I am just trying to make sure that anyone logging into my site are also valid users of the MySql database before allowing them to proceed into the site.

Cant someone help me?

Posted: Fri Dec 12, 2003 3:39 pm
by dbudde
Cant someone help me please?

Posted: Fri Dec 12, 2003 3:57 pm
by Weirdan
Does your

Code: Select all

mysql_select_db('mysql', $link) or die ('Cant connect to DB mysql : ' . mysql_error());
show any error? By default no one except user 'root' can access `mysql` database.

hmmmm, has me thinking

Posted: Fri Dec 12, 2003 4:27 pm
by dbudde
You know it does not give me an error, but you got me thinking because I think you are right about root usually only having access. I did give the user that I am trying with SELECT rights I think, I will have to look at that one. I will also try logging on as ROOT and see if that fixes my problem. Thanks for getting me thinking and I will get back with what I find ASAP.