uh... this is a bit of a mess... let's see if I can straigthend it out to the point where I can see what's wrong with it,
so read my comments
code:
<?php
error_reporting(E_ALL); //we want this baby to tell us about it's errors.
$dbh=mysql_connect ("localhost", "root", "triadpass") or die ('I cannot connect to the database because: ' . mysql_error());
//either use mysql_connect or die (which is a bit of bad style, honestly,
//or check for your database handle later on.
//when the script has died because of 'or die', it will *never* execute that piece of code you got in
//if (!$dbh)
mysql_select_db ("tuitionbd");
if (!$dbh)
{ //sticking to the one true bracing style will make your code easier to read.
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
die(); //either die or exit - don't use two aliases for the same function!
}
if (! @mysql_select_db("tuitionbd") )
{
echo( "<P>Unable to locate the TUITIONBD " .
"database at this time.</P>" );
die();
}
if($userlist = mysql_query("SELECT Fname,Lname,
Tel,address,level,cityname
FROM detail,city
WHERE detail.AID=city.AID
AND cityname='$cityname'")) //AND is a MySQL keyword as well. Capitalize it ;-)
{
while ($user = mysql_fetch_array($userlist))
{
$fname= $user["Fname"];
$lname = $user["Lname"];
$telephone= $user["Tel"];
$location = $user["address"];
$qualification= $user["level"];
//BROKEN CODE; -)
// echo( "<P>"$fname"<BR>" .
// "(by $location</A> )</P>" );
//you got your " tangled up. some dots are actually missing
//either use
// echo( "<P>". $fname. "<BR>" .
// "(by $location</A> )</P>" );
// or (better in my opinion
// echo( "<P>{$fname}<BR>" .
// "(by {$location}</A> )</P>" );
//oh. and what's that buisness with the closing a whene there's no opening a?
}
}
else
{
echo("<P>Error Showing details: " .
mysql_error() . "</P>");
}
?>
hope this helps,
Tyberius Prime