Hello Satish,
Ideally your mysql_select_db function should select the database. Please check the return value of the function. Alternatively you can programmatically issue the
USE
command.
<?php
mysql_query("USE sample", $conn);
?>
Still another way is to rewrite your query to include the database qualifier as shown below.
$sql = 'select * from sample.test';
$retval = mysql_query( $sql, $conn );
As a not of caution, I will encourage you to switch to
MYSQLi[
^] or
PDO_MYSQL[
^] extensions. The extension you are using is deprecated as of PHP 5.5.0, and will be removed in the future.
Regards,