10-08-2005, 02:32 PM
READ THIS
How can I access my database through PHP?You can create any custom PHP scripts to access your database. Below are a few lines of
PHP code that show you how to access your database:
<?php
$link = mysql_connect("mysql", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");
$query = "SELECT * FROM TABLE";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "$value\n";
}
}
mysql_close($link);
?>
Please note that you must replace USERNAME and PASSWORD with the user name and password that you have created for your
database. You must also replace TABLE and DATABASE with the valid table and database names from your database. The address of
the MySQL database server is just "mysql" -- a port number is not necessary.
SO I SHOULD use mysql instead of localhost?
How can I access my database through PHP?You can create any custom PHP scripts to access your database. Below are a few lines of
PHP code that show you how to access your database:
<?php
$link = mysql_connect("mysql", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");
$query = "SELECT * FROM TABLE";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "$value\n";
}
}
mysql_close($link);
?>
Please note that you must replace USERNAME and PASSWORD with the user name and password that you have created for your
database. You must also replace TABLE and DATABASE with the valid table and database names from your database. The address of
the MySQL database server is just "mysql" -- a port number is not necessary.
SO I SHOULD use mysql instead of localhost?
![[Image: vpa094.png]](http://www.virtualpilots.org/signatures/vpa094.png)