As I don't know PHP or MySQL very well, I've been working through the text "Practical PHP and MySQL: Building 8 Dynamic Web Applications" this weekend. Everything was going well until I began working on the shopping cart application.
Here is the code (which matches the book character-for-character) and the error I receive when loading the page:
The error I get on loading the main page is:
I've checked the other sites the author builds in the text and, other than variable naming, the logic is exactly the same ... so I'm guessing that I'm missing something. Since I don't want to go any further until I'm sure it's working (easier to debug now rather than later) I'm asking for any thoughts/comments on the above.
Thanks in advance.
Tom
P.S. Cross posted this in the php forum since I'm not sure exactly where the error lies.
"My mind is like a steel whatchamacallit ...
Here is the code (which matches the book character-for-character) and the error I receive when loading the page:
Code:
<h1>Product Categories</h1>
<ul>
<?php
$catsql = "SELECT * FROM categories;";
$catres = mysql_query($catsql);
while($catrow = mysql_fetch_assoc($catres))
{
echo "<li><a href='" . $config_basedir . "/products.php?id=" . $catrow['id'] . "'>" . $catrow['name'] . "</a></li>";
}
?>
</ul>
The error I get on loading the main page is:
Code:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\[URL unfurl="true"]www\shoppingcart\bar.php[/URL] on line 8
I've checked the other sites the author builds in the text and, other than variable naming, the logic is exactly the same ... so I'm guessing that I'm missing something. Since I don't want to go any further until I'm sure it's working (easier to debug now rather than later) I'm asking for any thoughts/comments on the above.
Thanks in advance.
Tom
P.S. Cross posted this in the php forum since I'm not sure exactly where the error lies.
"My mind is like a steel whatchamacallit ...