Forum Moderators: mack

Message Too Old, No Replies

php+apache+mysql+windows xp help needed?

         

octopus

2:31 am on Dec 28, 2004 (gmt 0)



I have windows xp professional installed on my computer, and I wanted to install php, apache server and mysql on my computer. Actually I have php 5.0.2, apache1.3.33 and mysql-4.1.7 installed and configured on my computer. I think my php and apache are configured correctly because when I go to the following web page using my browser [localhost...] I get the right message i.e. test ok! So far so good and then when I installed mysql and checked windows services both apache and mysql was started automatically. I was also able to log on to mysql in an interactive mode and create and modify a database I had just created. In order to test everything together including php, apache, and mysql I created another php file to test and connect to my database, but I got the following message. "Can not connect to mysql server". So I decided to test everything by going to the following page [localhost...] and everything is listed here including mysql.

I used this to create my database
mysql> CREATE DATABASE first_test;
Query OK, 1 row affected (0.31 sec)
mysql> USE first_test;
Database changed
mysql> CREATE TABLE people (
id int UNIQUE NOT NULL,
first_name varchar(40),
surname varchar(50),
PRIMARY KEY(id)
);
Query OK, 0 rows affected (0.24 sec)
mysql> INSERT INTO people VALUES(1,'Ann','Brache');
Query OK, 1 row affected (0.09 sec)
mysql> INSERT INTO people VALUES(2,'Narcizo','Levy');
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO people VALUES(3,'Tony','Crocker');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM people;
+----+------------+---------+
¦ id ¦ first_name ¦ surname ¦
+----+------------+---------+
¦ 1 ¦ Ann ¦ Brache ¦
¦ 2 ¦ Narcizo ¦ Levy ¦
¦ 3 ¦ Tony ¦ Crocker ¦
+----+------------+---------+
3 rows in set (0.19 sec)

And
GRANT ALL ON first_test.* TO pee_wee@localhost IDENTIFIED BY 'let_me_in'

All of this worked fine but when I tried the following

<?php
$username = "pee_wee";
$password = "let_me_in";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
// you're going to do lots more here soon
mysql_close($dbh);
?>
I got the message Unable to connect to MySQL.
I did this by using the book Beginning PHP 5 and MySQL from novice to professional and lots of online documentation and I don't know what else to do but I hope someone can help me out.

Thanks

coopster

2:58 pm on Dec 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, octopus.

Have a look at this recent thread regarding MySQL 4.1.7 problems [webmasterworld.com].