Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
Thread Tools
Old 11-09-2005, 09:49 AM   #1 (permalink)
Registered User
 
Join Date: Oct 2005
Posts: 12
OS: Win98 and XP


PHP/MySQL/Apache Connection Problems (10061)

I am having the following problem with the following configuration:
PHP 5.0.2
MySQL 4.0.20d
Apache 1.3.33
Windows XP Professional

PHP is working, as demonstrated by the phpinfo script I have run in the browser.
(<?php phpinfo() ?> )
MySQL will work fine from the command line, and starts as a service in Windows.

Apache is working, and will load my PHP pages, as well as html pages. However, when I try to use PHP to access MySQL, I get the following error “Cannot connect to the database server on ‘localhost’ (10061)”. I will walk through the steps I had to take to configure the server.

1. Installed MySQL 4.0.20d to c:\mysql
a. From the command line:
c:\mysql\bin\mysql -u root mysql
mysql>UPDATE User Password=PASSWORD(‘new password’)
>WHERE User=”root”;
mysql>FLUSH PRIVILEGES;

2. Unzipped PHP 5.0.2 to c:\php
a. Copied the “php.ini-dist” file to c:\windows.
b. Renamed to “php.ini” and made following changes.
i. extension_dir = “c:\php\ext”
ii. Enabled “php_mysql.dll” extension.
iii. session.save_path = “c:\windows\temp”
c. Copied php_mysql.dll, php_mysqli.dll, libmysql.dll, and libmysqli.dll to c:\windows. (This was the only way I could get PHP startup to find the files).
3. Installed Apache 1.3.33 to c:\Apache.

I did notice one thing. When I run phpinfo, under the mysql section, it lists the client API as 3.23. Does PHP5 not have support for MySQL 4.x? To further clarify, I have tried the same steps with differing combinations of PHP 4.3.9 and IIS, with the same results. The script I am using in PHP is as follows
<?php
$host = ‘localhost’;
$user = ‘root’;
$pass = ‘password’;
$dbcnx = @mysql_connect($host, $user, $pass);
if(!$dbcnx) { exit(‘mysqlerror()’) }
?>
This script works fine on remote servers, but I cannot get it to work on my local machine. Any suggestions? Thanks.

Last edited by wirvin : 11-09-2005 at 09:51 AM.
wirvin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-09-2005, 03:38 PM   #2 (permalink)
tgo
Registered User
 
Join Date: Jul 2005
Posts: 185
OS: slackware 10.1


Send a message via AIM to tgo
php5 does work with mysql 4 because thats what I use.

Its probally something easy you are missing so I would go in telnet (start - run - cmd) and do

telnet localhost 3306

if your on a network try:

telnet internal_ip 3306

then your external ip (can be found at www.whatismyip.com )

telnet external_ip 3306

if you cant connect to any of these then your mysql server isnt running right. Is the mysqldnt.exe (something close to that) running in the process list?

if you can connect to one of these and your php script cant that means your php.ini isnt correct. Heres what i have in my php.ini involving mysql.
-----------------------
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; Windows: "\path1;\path2"
include_path = "c:\php\ext;c:\mysql\bin"

extension=php_mysql.dll

-----------------------

make sure you have that extension line uncommented (wihtout a ; in front the line) and make sure you have the path to mysql so it knows where to look for the database.
__________________
My new homepage:
tgo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 11-10-2005, 09:13 AM   #3 (permalink)
Registered User
 
Join Date: Oct 2005
Posts: 12
OS: Win98 and XP


The key seems to be adding port 3306, so I will try that. The thing that gets me is that I am running PHP4.3/MySQL 4.0/Apache 1.3.33 on another (Windows 98SE) computer, and it is working wonderfully. The only difference is that MySQL is running as a service (mysqld-nt.exe) on the XP machine, and on the Windows 98SE machine I had to copy the shortcut (mysqld.exe) to my startup folder for it to start up automatically (It also worked to start MySQL manually after startup). I haven't added the "c:\mysql\bin" to my include_path, but I didn't do that on my 98SE machine, either.

The MySQL server seems to be running fine. It does start automatically as a service in Windows XP, and I can access it from the command prompt with no problems. As I said, my PHP scripts work fine on the Apache server. The only thing I can’t do is access MySQL with PHP. Could you email me a copy of your php.ini file (wirvin74@hotmail.com) so I can see what I may have missed? I would sure appreciate it. Thanks.

I do have a question about your include_path line. Did you have to move your php_mysql.dll file to the c:\windows\system32 directory for PHP startup to see it, or did adding c:\php\ext to your include_path allow startup to find that file? I had to move that file and libmysql.dll to system32 in order for PHP to startup properly.
wirvin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-28-2006, 11:33 PM   #4 (permalink)
Registered User
 
Join Date: Dec 2004
Location: BC
Posts: 28
OS: WinXP Pro/FC2


Thumbs Down sameProb

I'm having the same problem on my local box and I tried everything (or so it seems) including the telnet stuff mentioned above. When I want to go to any page that does not include interaction with the database things are fine. When I try to log in or see a product, the page refreshes and remains. The product images/paths show up fine since the images from the database are being produced. This could be just a Windows thing because I don't have this sort of problem with Fedora Core/Linux.
shylock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 04:50 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82