Selecting MySQL Database MYSQL

Selecting MySQL Database  

Selecting MySQL Database

Selecting a MySQL Database Using PHP Script

PHP provides function mysql_select_db to select a database. It returns TRUE on success or FALSE on failure.

Example

Here is an example showing you how to select a database.

<html>
   <head>
      <title>Selecting MySQL Database</title>
   </head>
   
   <body>
      <?php
         $dbhost = 'localhost:3036';
         $dbuser = 'guest';
         $dbpass = 'guest123';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
         
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         }
         echo 'Connected successfully';
         mysql_select_db( 'TUTORIALS' );
         
         mysql_close($conn);
      ?>
   </body>
</html>

Download free E-book of MYSQL


#askProgrammers
Learn Programming for Free


Join Programmers Community on Telegram


Talk with Experienced Programmers


Just drop a message, we will solve your queries