Problems...accessing database
Posted: Tue Dec 08, 2009 1:05 am
Hello All,
I having trouble accessing a database on another server.
Here is my code
Currently I am getting the following output:
When I add the username and password I get this message:
I am really confused. It seems that if I don't supply a password then i'm connected, but cannot access the database. It fails at the line (mysql_select_db("falldb_TX"). Or if I supply a username AND a password I cannot connect at all.
If someone can please give me some pointers that would be great.
Thanks.
I having trouble accessing a database on another server.
Here is my code
Code: Select all
<?php
$conn = mysql_connect('localhost','falldb_TX','austin') or die("Cannot connect to database");
if($conn)
{
echo "Connected successfully<br>";
}
else
{
echo "Connection not established<br>";
}
mysql_select_db('falldb_TX') or die(mysql_error());
echo "Connected to database";
$result = mysql_query("SELECT * FROM Students", $conn) or die (mysql_error());
$num = mysql_numrows($result);
mysql_close($conn);
$i = 0;
while ($i < $num)
{
$banner=mysql_result($result, $i, "Banner");
$first=mysql_result($result, $i, "First Name");
$last=mysql_result($result, $i, "Last Name");
$address=mysql_result($result, $i, "Street Address");
echo "<b>$banner</b> First: $first <br> Last: $last <br> Address: $address<br>";
$i++;
}
?>
Code: Select all
You're connected.
Access denied for user ''@'localhost' to database 'falldb_tx'
Code: Select all
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'falldb_TX'@'localhost' (using password: YES) in C:\wamp\www\Project\dbConfig.php on line 3
Cannot connect to database
If someone can please give me some pointers that would be great.
Thanks.