Solved

Can't connect to mysql through php4

Posted on 2006-07-02
10
592 Views
Last Modified: 2009-12-16
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
0
Comment
Question by:sittnduck
  • 6
  • 3
10 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17027494
>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?
 
0
 

Author Comment

by:sittnduck
ID: 17027541
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
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17027556
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).
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:sittnduck
ID: 17027567
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?
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 17027765
then, please post the php code you use to connect, do you use mysql_error() to show any connection errors?
0
 

Author Comment

by:sittnduck
ID: 17027840
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?
0
 

Author Comment

by:sittnduck
ID: 17027903
Access denied for user 'ODBC'@'localhost' (using password: NO)
0
 

Author Comment

by:sittnduck
ID: 17027964
<?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.
0
 
LVL 21

Assisted Solution

by:Julian Matz
Julian Matz earned 200 total points
ID: 17028334
<< Access denied for user 'ODBC'@'localhost' (using password: NO)
It means that your $mypassword variable is most likely an empty string...
Try entering your login details directly...
0
 

Author Comment

by:sittnduck
ID: 17028793
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!
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove lines by logo 2 37
Select only the top record in a left join 13 45
Best environment for cross platform web development? 5 55
Create an automated page index 9 53
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question