MySql login and authentication help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dbudde
Forum Commoner
Posts: 25
Joined: Mon Dec 01, 2003 4:02 pm
Location: Chicago, IL

MySql login and authentication help

Post 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);
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: MySql login and authentication help

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: MySql login and authentication help

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: MySql login and authentication help

Post 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 :)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

I wasn't sure which word to use ;)
dbudde
Forum Commoner
Posts: 25
Joined: Mon Dec 01, 2003 4:02 pm
Location: Chicago, IL

ok, i will try to clarify

Post 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.
AnsonM
Forum Commoner
Posts: 72
Joined: Thu Sep 25, 2003 7:21 am

Post 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
dbudde
Forum Commoner
Posts: 25
Joined: Mon Dec 01, 2003 4:02 pm
Location: Chicago, IL

I believe what you are saying is correct.

Post 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.
dbudde
Forum Commoner
Posts: 25
Joined: Mon Dec 01, 2003 4:02 pm
Location: Chicago, IL

bad grammar

Post 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.
dbudde
Forum Commoner
Posts: 25
Joined: Mon Dec 01, 2003 4:02 pm
Location: Chicago, IL

Cant someone help me?

Post by dbudde »

Cant someone help me please?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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.
dbudde
Forum Commoner
Posts: 25
Joined: Mon Dec 01, 2003 4:02 pm
Location: Chicago, IL

hmmmm, has me thinking

Post 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.
Post Reply