db refusing php interaction

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
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

db refusing php interaction

Post by m3rajk »

my php scripts keep having their connections to mysql refused. the passords come from a seperate file that's in the include.

the pws work, i know because i tested each one by copying and pasting from that file.

http://24.91.157.113/findyourdesire/join.showcode

that file has had a small amount of editing fromt he actual file, which is noted at the top.

this is a print out from mysql that shows the users (logins edited)
http://24.91.157.113/findyourdesire/SQLUserInfo

i've tried adjusting the user being used in that script to Ashes and to localhost, both to no avail

since there's a hardware firewall on my network i turned off the software firewall on my server to be sure that's not the issue.

can anyone help me get this running?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

When you try to run the PHP script what is the mySQL error message?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

Warning: Access denied for user: 'login@localhost' (Using password: YES) in /var/www/html/findyourdesire/join.php on line 30
cannot access db
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Is the mySQL server running on a 2000 machine?

I have had the same problem with 2000 machines.

I did this to fix it:

delete from user where Host='%';
delete from user where User='';
delete from db where Host='%';
update user set User='NewRootName', Password=password('NewPassword') where User='root';
flush privileges;

Try that, restart the mySQL server, then tell me if it worked :)
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

heh. apparently you haven't seen me kvetch about winblows.

no. i have a LAMP environment i'm developing in.
and i know that wont work because non of the users are having issues are root



maybe this will help (it's the second page i link to)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13 to server version: 3.23.56

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW TABLES;
+-----------------+
| Tables_in_mysql |
+-----------------+
| columns_priv |
| db |
| func |
| host |
| tables_priv |
| user |
+-----------------+
6 rows in set (0.00 sec)

mysql> SELECT host,user FROM user;
+-----------+--------+
| host | user |
+-----------+--------+
| % | login |
| % | login2 |
| % | login3 |
| % | login4 |
| Ashes | root |
| localhost | root |
+-----------+--------+
6 rows in set (0.22 sec)

mysql> SELECT host,user,db FROM db;
+------+--------+----------------+
| host | user | db |
+------+--------+----------------+
| % | login | findyourdesire |
| % | login2 | findyourdesire |
| % | login3 | findyourdesire |
| % | login4 | findyourdesire |
+------+--------+----------------+
4 rows in set (0.16 sec)

mysql>
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Yea, I honestly don't know enough about mySQL to help you out here. Sorry :(
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

maybe someone else on here does....
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

cant help sorry :(
i had to bribe apache to accept php, and my sql db is taped up with duct tape and a bit of chewing gum :/ (ie i stared at the screen for 6 hours and it suddenly started working... dont really know how :/ )
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

it doesn't like mysql_connect() either
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

m3rajk wrote:Warning: Access denied for user: 'login@localhost' (Using password: YES) in /var/www/html/findyourdesire/join.php on line 30
cannot access db
I don't get it!
Do you get the

Code: Select all

$db=mysql_pconnect('Ashes', 'login', $pw) or die("cannot access db");
"cannot access DB" script death too?
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

You do!
And I quote it even!... Sorry!
I'll go back to treading course right away, sorry!

Did you tried to echo the value of your password var, just to make sure it really contains the right password?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

i copied and pasted into cli to make sure it was right. it's in an included file
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

well... if you'd like to see what ehappened elsewhere....
http://www.webmaster-forums.net/showthr ... adid=22135

that place seems better in dealing with dbs, but this place makes their helping out with php look pathetic. then again this is devoted only to php and is much much more active


this post by suzanne made me double check something "Looks to me like that username or password is wrong. That's the error I get when I move things from one server to another and fail to change the information in my happy connection function first. "

which lead to my response...
myself at a diff board wrote:i now know the original problem was that i was using mysql_pconnect(). when that didn't work i started on the forums and reasoning that out. i noticed in the db file (where i define the passwords) i later redefine bot $visitor and one other password for use in the forums. so i changed the forum one since only one page calls that. much easier to fix in one page than about a dozen pages.

anyway, as soon as i did that, i got this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/findyourdesire/join.php on line 34

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/findyourdesire/join.php on line 40
sending to sql: INSERT INTO users (username, password, email, last_login_ip, last_login_date, enroll, gender) VALUES (neo, 9cc9e1f6a22e05307d6831087ef5d1e6, <myemail (yes this is an edit)>, 192.168.1.1, 2003-08-20 18:32:09, 2003-08-20 18:32:09, M)
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/findyourdesire/join.php on line 173

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/findyourdesire/join.php:34) in /var/www/html/findyourdesire/join.php on line 178

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/findyourdesire/join.php:34) in /home/joshua/includes/fyd.funcs.php on line 42

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/findyourdesire/join.php:34) in /home/joshua/includes/fyd.funcs.php on line 43

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/findyourdesire/join.php:34) in /home/joshua/includes/fyd.funcs.php on line 44

Warning: Cannot add header information - headers already sent by (output started at /var/www/html/findyourdesire/join.php:34) in /home/joshua/includes/fyd.funcs.php on line 45
followed by the next page.
th header issues are an expected result of the debugging line i have in there. i do have a question now... the db has nothing in it. is that why i'm getting the invalid resource? or is that caused by something else?

and Suzanne, i don't know why, but it's you last post that made me think to check for a double declaration.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Just wondering, how is what she said any different than those of us asking you to double check/echo out the password/usernames to double check the value?
Post Reply