The following code is give me an error "No Database Selected"
Could someone help me out ? Thanks !
Ajay
</head>
<body>
<?php
$link = mysql_connect("localhost", "user", "pass")
or die("Could not connect: " . mysql_error());
echo "Connected successfully";
$result = mysql_query('select col1, col2, col3 from mytable');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
<?php
function mysql_result_all($result) {
for($i = 0; $i < mysql_num_fields($result); $i++) {
echo '<th>';
echo mysql_field_name($result,$i);
echo '</th>';
}
while($row = mysql_fetch_array($result)) {
echo '<tr>';
for($i = 0; $i < count($row); $i++) {
echo '<td>'.$row[$i].'</td>';
}
echo '</tr>';
}
echo '</table>';
}
?>
<table>
<?php
mysql_result_all($result);
mysql_close($link);
?>