I'm getting the following error with this code below.
Error performing query: No database selected
I'm pretty sure it has something to do with the SQL variable, but I've tried everything I can, I even had the mySQL generate the code for me and it's still broken. It doesn't say Could Not Connect, so I konw it's connecting, but then the SQL is the next step, where I believe it's broken.
What can I do do fix it?
PHP Code:<?php
$server = "ipaddress"; // this is the server address
$username = "username"; // mysql username
$password = "password"; // mysql password
$link = mysql_connect ($server, $username, $password)
or die ("Could not connect");
$sql = 'SELECT * FROM `Learning` LIMIT 0, 30 ';
$result = mysql_query($sql, $link);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo($row["Artist"] . " ");
echo($row["Title"] . " ");
echo($row["Year"] . "<br>");
}
?>





Bookmarks