# Solved: MySQL Error: No database selected



## pcpro17

Hello. I'm trying to query out of a MySQL database that I made. It is a very simple todo list database with only one table, four fields, and one record.


PHP:


      $mysql_db = mysql_connect( $db_server, $db_username, $db_password ) or die( "MySQL Error: ".mysql_error() );

      if ( $mysql_db != false )
      {
         $query = "SELECT todo_item FROM todo_list_table";

         $result = mysql_query( $query, $mysql_db ) or die( "MySQL Error: ".mysql_error() );

         mysql_close( $mysql_db ) or die( "MySQL Error: ".mysql_error() );
      }

When it gets to mysql_query I keet getting a "No database selected" error. Does anyone have any suggestions? Thanks.


----------



## tomdkat

Read about mysql_select_db().

Peace...


----------



## pcpro17

Thanks, Tom! That did the trick!


----------



## tomdkat

Coolio!

Peace...


----------

