MySQL Forums
Forum List  »  Newbie

cannot connect to my database using php
Posted by: Caroline Badley
Date: August 17, 2005 04:46AM

Hi I am using SAMS teach yourself to learn how to work with php, mysql and apache.

I am using PHP 5.0, Mysql 4.0 and Apache 2.0 (which I am running as 'localhost' on port 8080) on my XP prof machine.

The apache server is running and I have been able to run some simple PHP scripts on it. I have installed mysql and have added tables and data to the 'test' database.

I have not been able to access the database through, however, using the following script:

<?php
$conn = mysql_connect("localhost", "username", "password");
echo $conn;
?>

Its supposed to give me something like Resource id #1.

Instead I get a blank screen. I have been confused by the mysql connecting - initially I set up a username and password through the mysqladmin - which it prompted me to do when I first ran it - but this did not allow me to connect using these details through the console. I was able to add tables etc as a user I did not set up though - odbc@localhost.

I have since worked out how to connect in through the console as the root user and have set up the username and password (using GRANT ALL on the 'test' database)again and I can now connect to the database through the console with that username and password. The script still does not work using that username/password. Could I be using the wrong username/password? Can I somehow use the root username to connect?

HELP - i have checked the documentation on this site but am none the wiser.

thanks, Caroline

Options: ReplyQuote


Subject
Written By
Posted
cannot connect to my database using php
August 17, 2005 04:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.