I am a newbie trying to conect my webpage (index.php) to a MySQL database. I am using myphpadmin for editing and have configured the necessary file but I cannot connect. I get "No Database Selected" on the webpage. This is the code for index.php.
Can anyone tell by this if I am doing something wrong? The host, user, password and db name have been ommitted for this posting..
<?PHP
error_reporting(E_ALL^E_NOTICE);
//insert mysql_connect(); and mysql_select_db(); calls here
// make connection to database
$hostName = "localhost";
$userName = "user";
$password = "pass";
$dbName = "dbName";
// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
$date = '<select name="date">';
$agency = '<select name="agency">';
$city = '<select name="city">';
$result = mysql_query("SELECT date,agency,city FROM agencies") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$date .= '<option value="'.$row["date"].'>'.$row["date"].'</option>';
$agency .= '<option value="'.$row["agency"].'>'.$row["agency"].'</option>';
$city .= '<option value="'.$row["city"].'>'.$row["city"].'</option>';
}
$date .= '</select>';
$agency .= '</select>';
$city .= '</select>';
/*removed echo lines,this would just give you the dropdowns at the top of the page for no real reason */
?>