If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > phpmyadmin-mysql "No Database Selected"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-01-04, 15:48
bufhal bufhal is offline
Registered User
 
Join Date: May 2004
Posts: 2
phpmyadmin-mysql "No Database Selected"

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 */
?>
Reply With Quote
  #2 (permalink)  
Old 05-01-04, 16:36
snorp snorp is offline
Registered User
 
Join Date: Apr 2004
Location: Europe->Sweden->Stockholm
Posts: 71
Do one of the following:

In your SELECT, name the database explicitly.
Example: SELECT something FROM database.table WHERE condition.

OR

Use the PHP function mysql_select_db("database", $dbconnection) to specify the database you wish to use for your queries.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On