I'm writing a simple weblog, and I'm new to PHP; but thanks to this particular resource, I'm learning more and more. With that said, I'm making some mistakes, which I need help finding solutions for. I'm receiving these three Warning/Errors:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in /Users/laurenyoung/Sites/blogtastic/viewcat.php on line 20
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /Users/laurenyoung/Sites/blogtastic/viewcat.php on line 20
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /Users/laurenyoung/Sites/blogtastic/viewcat.php on line 22
And my code is:
<?php
require("includes/config.php");
if(isset($_GET['id']) == TRUE) {
if(is_numeric($id) == FALSE) {
$error = 1;
}
if($error == 1) {
header("Location: " . $config_basedir . "/viewcat.php");
}
else {
$validcat = $_GET['id'];
}
}
else {
$validcat = 0;
}
$sql = "SELECT * FROM categories";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)) {
if($validcat == $row['id']) {
echo "<strong>" . $row['cat'] . "</strong><br />";
$entriessql = "SELECT * FROM entries WHERE cat_id = " . $validcat ." ORDER BY dateposted DESC;";
$entriesres = mysql_query($entriessql);
$numrows_entries = mysql_num_rows($entriesres);
echo "<ul>";
if($numrows_entries == 0) {
echo "<li>No entries!</li>";
}
else {
while($entriesrow = mysql_fetch_assoc($entriesres)) { echo "<li>" . date("D jS F Y g.iA", strtotime($entriesrow['dateposted'])) ." - <a href='viewentry.php?id=" . $entriesrow['id'] . "'>" . $entriesrow['subject'] ."</a></li>";
}
}
echo "</ul>";
}
else {
echo "<a href='viewcat.php?id=" . $row['id'] . "'>" . $row['cat'] .
"</a><br />";
}
}
require("includes/footer.php");
?>
Could someone <kindly> explain what my issue is here?
Thanks