Solved

Can't connect to mysql through php4

Posted on 2006-07-02
10
594 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

632 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