Solved

Can't connect to mysql through php4

Posted on 2006-07-02
10
588 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 142

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 142

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
 

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 142

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
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:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now