Jump to content

Recommended Posts

Every time I try to set up a web server on my windows computer I get to this step and then flounder.

I've installed php and it's working grandly with apache.
I've installed and set up mysql, and reset the root pw and whatnot.
Both the apache2 and mysql services are running.
The "php_mysql.dll" line in php.ini is uncommented
The extensions line in php.ini is set correctly to c:\php\ext
Both c:\php and the mysql directory are in the PATH variable

yet when I try to connect to mysql from php I get "Can't connect to MySQL server on 'localhost'" (I got that from a failed IPB setup error message)

also when i view phpinfo, I have a section for mysql in the modules section. php's correctly identified my mysql client api version, but I suspect that's libmysql.dll talking and not mysql.exe

Have I missed a step here? The last time I had this problem I remember it being resolved by downloading some old mysql dll and pasting it all through the php dirs and the windows directories. But I'm using the 2nd-to-newest version of apache2, the 2nd-to-newest version of mysql, and a tested copy of ipb2. I fail to understand what's wrong, my configuration fits the instructions on [a href=\"http://php.net/mysql\" target=\"_blank\"]this page[/a], and i've restarted several times. PHP plays nicely with apache, mysql is cooperative through the command prompt, but PHP just can't connect to mysql. I'm sure I set up mysql and apache correctly during their installations -i manually installed php though so i don't know if I missed something there- so I must have missed something in getting them to interact

help?
Link to comment
https://forums.phpfreaks.com/topic/8328-php-mysql-integration/
Share on other sites

If you you are installing IPB2 then make sure your details yiur are entering upon installation are correct.

For now try this:
[code]<?php

$conn = mysql_connect("localhost", "root", "rootPassword") or die("Unable to connect mysql: " mysql_error());

mysql_select_db("mysql") or die("Unable to select database: " . mysql_error());

echo "PHP was able to succesfully connect to MySQL and manage to select the mysql database too!";

?>[/code]

Before running the above code, make sure you change where it says [b]rootPassword[/b] to the actually password your set for your mysql installation, dont use your computer username password.

Now run the code in the browser. If you get the following message:
[code]PHP was able to succesfully connect to MySQL and manage to select the mysql database too![/code]Then php was able to connect to mysql and so PHP is talking to mysql and vise versa.

If you dont can you post the full error message(s) here.
Link to comment
https://forums.phpfreaks.com/topic/8328-php-mysql-integration/#findComment-30442
Share on other sites

[!--quoteo(post=368328:date=Apr 25 2006, 04:45 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 25 2006, 04:45 AM) [snapback]368328[/snapback][/div][div class=\'quotemain\'][!--quotec--]
If you you are installing IPB2 then make sure your details yiur are entering upon installation are correct.

For now try this:
[code]<?php

$conn = mysql_connect("localhost", "root", "rootPassword") or die("Unable to connect mysql: " mysql_error());

mysql_select_db("mysql") or die("Unable to select database: " . mysql_error());

echo "PHP was able to succesfully connect to MySQL and manage to select the mysql database too!";

?>[/code]

Before running the above code, make sure you change where it says [b]rootPassword[/b] to the actually password your set for your mysql installation, dont use your computer username password.

Now run the code in the browser. If you get the following message:
[code]PHP was able to succesfully connect to MySQL and manage to select the mysql database too![/code]Then php was able to connect to mysql and so PHP is talking to mysql and vise versa.

If you dont can you post the full error message(s) here.
[/quote]


there is no output at all

is there some error reporting i should enable?
Link to comment
https://forums.phpfreaks.com/topic/8328-php-mysql-integration/#findComment-30543
Share on other sites

Oops had a slight typo in the code provided. Change this line:
[code]$conn = mysql_connect("localhost", "root", "rootPassword") or die("Unable to connect mysql: " mysql_error());[/code]to[code]$conn = mysql_connect("localhost", "root", "rootPassword") or die("Unable to connect mysql: " . mysql_error());[/code]

Also I think you have error reporting turn off. You should turn on error reporting which you can do by editing the php.ini file and finding the line that says [b]display_errors = Off[/b] to [b]display_errors = On[/b]

Now save your php.ini file and restart your Apache webserver.
Link to comment
https://forums.phpfreaks.com/topic/8328-php-mysql-integration/#findComment-30593
Share on other sites

[!--quoteo(post=368484:date=Apr 25 2006, 11:18 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 25 2006, 11:18 AM) [snapback]368484[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Oops had a slight typo in the code provided. Change this line:
[code]$conn = mysql_connect("localhost", "root", "rootPassword") or die("Unable to connect mysql: " mysql_error());[/code]to[code]$conn = mysql_connect("localhost", "root", "rootPassword") or die("Unable to connect mysql: " . mysql_error());[/code]

Also I think you have error reporting turn off. You should turn on error reporting which you can do by editing the php.ini file and finding the line that says [b]display_errors = Off[/b] to [b]display_errors = On[/b]

Now save your php.ini file and restart your Apache webserver.
[/quote]
[code]
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 3
Unable to connect mysql: Can't connect to MySQL server on 'localhost' (10061)
[/code]

there you go, it's what I said from the beginning

thanks for your help so far

--RESOLVED!
I reinstalled mysql, but this time with tcp/ip connections enabled. works fine now thanks
Link to comment
https://forums.phpfreaks.com/topic/8328-php-mysql-integration/#findComment-30738
Share on other sites

Hi the reason why your cannt connect to mysql was becuaser mysql wasnt running and so you go the error. Whne you install MySQL you shoulf of installed it as a service this whay MySQL will start up automatically in the background when you boot into Windows.

[b]EDIT:[/b] Oops Didn't see the following:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]--RESOLVED!
I reinstalled mysql, but this time with tcp/ip connections enabled. works fine now thanks[/quote]
Link to comment
https://forums.phpfreaks.com/topic/8328-php-mysql-integration/#findComment-30874
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.