Link to home
Start Free TrialLog in
Avatar of sittnduck
sittnduck

asked on

Can't connect to mysql through php4

I am a newb, I'm sure you guys have never heard that one before.

Web Server specs

iis 6
mysql 5
php 4

Ok, I am trying to get VSP stats to work...a php script that generates stats for multiple pc games. I had php5 and mysql5 functioning ok, at least well enough to be able to install phpbb. I tried installing VSP but when I would browse to index.php to view the skin I would get a blank page. So after reading through their knowledge base, I found that a lot of people (not everyone) had trouble installing vsp using php5 so I downgraded. It now tries to load the vsp skin but I get "could not connect to database". I also get the same error when I try to re-install phpbb. The way I understand it is that mysql support is builtin to php4. You aren't supposed to have to do anything but I realize it's not always as simple as that. PHP is working, the link between php and mysql seems to be broken.

Please help this newb,
Josh
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>the way I understand it is that mysql support is builtin to php4.
you have to check if the php_mysql.dll is really enabled (ie not decommented) in the (relevant) php.ini file.
to check, run a php file on the server with phpinfo() function, and cofirm with the output.

>but I get "could not connect to database".
* is the mysql up and running (this might sound silly question, but I have seen too many people saying "outsch..." after that question)
* does the php code use the correct connection settings? can you connect locally with mysql command line tool? can you validate the connection permissions?
 
Avatar of sittnduck
sittnduck

ASKER

First off, thank you for responding!

In the relevant php.ini, there is no line for "php_mysql.dll" under extensions. Should I add that line and upload the dll? "Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it." is why I assumed it was builtin and ready for action.

MYSQL is running and I in no way consider that a silly question at this point. I am a newb! It is running however, I can work from a command line in it.

Does this help?

http://67.14.214.83/test.php
you are correct, in php 4.4.x the mysql in built-in, so no issue there.
note that you should remove the test.php ASAP again.

can you connect to mysql with external programs (mysql command line for example).
test.php has been deleted, it made me nervous to make that available but I thought maybe it would be of use.

I can work from a command line and I can also connect via navicat which you may already be familiar with. If not it is a third part sql management tool. Is that what you are looking for is it not a true test to see if mysql is working with external programs?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you want the install.php script's code for phpbb? I haven't customized it. It worked before with php5 and mysql5, I never had to add or modify a line in it to get it to connect to mysql and create the db. Now, with mysql4 and php4 I get "could not connect to database" when trying to install. I can send you the code but it seems like it is maybe something in the php4 config not allowing me to connect(because the phpbb install script's code has not changed, what has changed is I have now reverted back to php4 to try and vsp stats to work). Let me know if you still want me to post that code. Can you give me the necessary php code to test the connection to mysql? To see if it gives me any more details as to what the problem is?
Access denied for user 'ODBC'@'localhost' (using password: NO)
<?php
include("config.php");
mysql_connect("$localhost", "$myusername", "$mypassword");
mysql_select_db("$mydb");
echo mysql_error();
phpinfo();
?>

That's the code I used that gave me the error above.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I figured it out, I had to run the following command for each of the user accounts I had created because
of the different password authentications. It resolved the problem.

SET PASSWORD FOR 'zoooz'@'some_host' = OLD_PASSWORD('mypass');


Thank you both for responding.

I will award both points because I am appreciative of your input. AngelIII, you helped me narrow it down by using a php connect mysql test script. The  error it gave me pointed me in the right direction.

Thanks!