- Connecting to a mysql server, it's the most of time installed in the same server where php is, so we uselocalhost as address of mysql server.mysql_connect("localhost", "username", "password") or die(mysql_error());
echo "Connected to MySQL Server";
Some times, when you are running a server in your own computer and not a hosting service provider's, you can connect with just indicating username "root" with no password, and some times is no need to enter an username. It's all depend on your current mysql configuration. - After you are connected to a mysql server, you need then to connect to a mysql database:mysql_select_db("database-name") or die(mysql_error());
echo "Connected to Mysql Database";
Connect to Mysql Database
Connecting to the mysql database is done in two steps:
1 comments:
- John Mueller said...
-
Hi, how do you explain that sometimes Mysql disconnects just by itself in a PHP script and I have to reconnect ??
- September 17, 2009 at 5:20 AM
Subscribe to:
Post Comments (Atom)
Search With Google
Categories
- 1-General (3)
- 2-Getting started (4)
- 3-Strings (10)
- 4-Server config (1)
- 5-Best scripts (7)
- email (4)
- files (6)
- Forms (3)
- If statements (3)
- Loop statements (2)
- Mysql (2)
- Server variables (3)
- Sessions (1)
- Tutorials-planet.com (1)
- web hosting (1)
- You need a programmer ? (1)