I made a database in the localhost part of Navicat 8 for MySQL called testu.
i put an sql file in there but thats not the problem...
in a php file i put:
Code:
<?php
// Connecting, selecting database
$link = mysql_connect('localhost')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully<br>';
mysql_select_db('testu') or die('Could not select database<br>');
// Performing SQL query
$query = 'SELECT * FROM username';
$result = mysql_query($query) or die('Query failed: ' . mysql_error() . "<br>");
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
I downloaded wamp. I type in the address bar: localhost/phpfilename.php
and what appered was:
Connected successfully
Could not select database
what is the problem?
i put the correct name for the database..