db.php problem, please 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
Hoshi
Forum Newbie
Posts: 4
Joined: Sun Aug 24, 2003 1:17 am

db.php problem, please help ^-^

Post by Hoshi »

This is my db.php, I'm not sure if all the things are rite, please correct me, if I'm wrong.
<?
/* Database Information - Required!! */
/* -- Configure the Variables Below --*/
$dbhost = '69.57.142.60';
$dbusername = 'abna@abna.ca';
$dbpasswd = '***********';
$database_name = 'abna_ca';

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>
but when i try to get into the database it gives me this
Warning: mysql_pconnect(): Access denied for user: 'abna@abna.ca@ensim.com' (Using password: YES) in /home/virtual/site82/fst/var/www/html/Vilky/Login/db.php on line 11
Couldn't connect to server.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

looks like either your login/password combination is wrong or you're trying to access a database you're not allowed to.

btw. there's no need to quote your string-variables when used as parameters.
$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")

Code: Select all

$connection = mysql_pconnect($dbhost, $dbusername, $dbpasswd)
Hoshi
Forum Newbie
Posts: 4
Joined: Sun Aug 24, 2003 1:17 am

^-^

Post by Hoshi »

That might be it, but can you tell me why does "@ensim.com" always comes up, when I try to login in?

I haven't typed that in my db.php, yet it always come on.

http://www.abna.ca/VC/Login/login_form.html
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

that's the origin of the request (where the client is located; in this case the php-script) as seen by the mysql-server.
If you were on the same host it would print something like abna@abna.ca@localhost. Permissions can be granted (and denied) by the origin.
You should ask your provider how to connect to the server or -if you run this system- take a look at http://www.mysql.com/doc/en/Adding_users.html
in either case http://www.mysql.com/doc/en/Access_denied.html might shed up some light on this
Hoshi
Forum Newbie
Posts: 4
Joined: Sun Aug 24, 2003 1:17 am

Post by Hoshi »

First, use the mysql program to connect to the server as the MySQL root user:

shell> mysql --user=root mysql
Then you can add new users by issuing GRANT statements:

mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO admin@localhost;
mysql> GRANT USAGE ON *.* TO dummy@localhost;
Ok, I follow the direction, but than it tells me to add users, yet it doesn't tell me where, just that connect as the root user.

P.S: I'm using PhpMyAdmin program.

Oh, and I'm wondering

Image

What would be the database name?
abna_ca
or
users?
User avatar
trollll
Forum Contributor
Posts: 181
Joined: Tue Jun 10, 2003 11:56 pm
Location: Round Rock, TX
Contact:

Post by trollll »

Database name of "abna_ca" and it has a table named "users" in it.
Hoshi
Forum Newbie
Posts: 4
Joined: Sun Aug 24, 2003 1:17 am

Post by Hoshi »

I think that if a person that register on the website, the file automatic adds the user on to my database, so I don't have to add users manually, right?

I was wondering if you could tell me what i should be checking here.
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND

password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
Please, and Thank You

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site82/fst/var/www/html/VC/Login/checkuser.php on line 21
Post Reply