my sql connecteivity issue
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. all users made specifically for this site)
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
t's a LAMP development environtment, there;s a router providing firewall resticting connections to the machine to just ftp/ssh/htttp if you're not on my network. 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?
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Mark Hensler posted this at 16:25 — 18th August 2003.
He has: 4,048 posts
Joined: Aug 2000
$db=mysql_pconnect('Ashes', 'login', $pw) or die("cannot access db"); # connect
'What the heck is "Ashes"?Are you running the PHP on one server, and the mySQL on another? If you have a LAMP environment, then everything should be on the same server, so you should have the `Host` field set to `localhost` (in the DB and in the PHP connect call).
BTW... this ain't gonna work:
<?php
// (commented out so this file wont be parsed
?>
Mark Hensler
If there is no answer on Google, then there is no question.
m3rajk posted this at 18:54 — 18th August 2003.
They have: 461 posts
Joined: Jul 2003
there's just one machine. it's name is Ashes.
i've already switched them to localhost in that file. no change.
Suzanne posted this at 21:53 — 18th August 2003.
She has: 5,507 posts
Joined: Feb 2000
Here's what I do, it may help:
$server = 'servername';
$username = 'username';
$password = 'password';
$flags = 'whatever flags you want to set';
THEN:
function connectdatabase() {
$thisothervariable = mysql_pconnect($server, $username, $password, $flags);
}
http://ca3.php.net/mysql_pconnect
Emphasis is mine.
Mark Hensler posted this at 22:00 — 18th August 2003.
He has: 4,048 posts
Joined: Aug 2000
You need to change everythig in PHP to 'localhost', as well as the `Host` field in the `mysql` dabatase.
And try mysql_connect() instead of persistent connections. (personally, I never use persistent connections)
Mark Hensler
If there is no answer on Google, then there is no question.
m3rajk posted this at 14:51 — 19th August 2003.
They have: 461 posts
Joined: Jul 2003
hmm...
suzanne: if that means cgi module then i can't use it.
mark: the mysql book i have suggests using it.
10:51 - made sure all host feilds related to visitor are localhost and flushed privileges, and double checked join.php
result of test
Warning: MySQL Connection Failed: Access denied for user: 'visitor@localhost' (Using password: YES) in /var/www/html/findyourdesire/join.php on line 30
cannot access db
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
mairving posted this at 15:11 — 19th August 2003.
They have: 2,256 posts
Joined: Feb 2001
Have you trying connecting from the shell, assuming that you have shell access?
mysql db_name -u username -ppassword
This will tell you if your user can actually connect to mysql.
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
Suzanne posted this at 16:13 — 19th August 2003.
She has: 5,507 posts
Joined: Feb 2000
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.
m3rajk posted this at 17:30 — 20th August 2003.
They have: 461 posts
Joined: Jul 2003
i've used the shell to verify that both the username and password work. the file with the db functions has the variable $pw set as $pw='thepassword';
so unless it also has the '' it should be exactly the same thing as i type into the shell
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Suzanne posted this at 17:38 — 20th August 2003.
She has: 5,507 posts
Joined: Feb 2000
So your username is visitor and your password is "thepassword" and this doesn't work?
How do you have it in your script?
***
I should point out that my function has nothing to do with modules for PHP, but rather using mysql_pconnect() only works if PHP is a module, not compiled with Apache.
Try using the more standard (and probably better for your application in this case) mysql_connect() and set up a nice function to serve you.
<?php
$server = 'servername';
$username = 'username';
$password = 'password';
function connectdatabase() {
$connected = mysql_connect($server, $username, $password);
}
?>
m3rajk posted this at 18:10 — 20th August 2003.
They have: 461 posts
Joined: Jul 2003
i have switched it to mysql_connect (in all my files) it's still not doing it, "thepassword" is not the password for the user, it's just what i used for an example. but i'm thinking your suggestion on having host and usernames as variables int he db file makes sense, and i just thought of something else.... i'm including a few pages, i should doublecheck that $visitor is defined ONLY once
edit:
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:
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.
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Mark Hensler posted this at 19:00 — 20th August 2003.
He has: 4,048 posts
Joined: Aug 2000
No, results should always be valid, regardless if anything is returned from the query.
Suzanne, watch your scope...
global $server, $username, $password;
Mark Hensler
If there is no answer on Google, then there is no question.
Suzanne posted this at 19:17 — 20th August 2003.
She has: 5,507 posts
Joined: Feb 2000
Thanks Mark, noted.
Those errors show up when you have other problems with the query, but at least you're connecting now. Check your variables, check your syntax, and make sure you're asking for the right things.
I use mysql_error() a LOT and echo ""; exit; after every thing when I have errors to debug line by line.
m3rajk posted this at 18:48 — 23rd August 2003.
They have: 461 posts
Joined: Jul 2003
i've done that. it's having issues with the @ in the e-mail address. i'm looking o see if i can find anything that will dealw ith that automatically while writing the forum display and tweaking the control panels on interests.. and possibly the sign up...
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.