&nb"/>
Home >Backend Development >PHP Tutorial >How can we select a MySQL database using PHP script?
We know that PHP provides a function called mysql_select_db to select a mysql database.
To illustrate this, we will use a PHP script in the following example to select a database called "Tutorial".
<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>
The above is the detailed content of How can we select a MySQL database using PHP script?. For more information, please follow other related articles on the PHP Chinese website!