PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
That's my code.
mysql_fetch_array() expects parameter 1 to be resource, boolean given in line "$result = mysql_fetch_array($query); " and also in line "while ($result = mysql_fetch_array($query)) "
When I remove WHERE category = $cat all goes well except the result. It says "array array array array array" and so on
Thanks
You are doing wrong if it asking about category you are assigning full string how it will compare.
Wrong Method :
if (isset($_GET['cat'])) {
$cat = $_GET['cat'];
} else { $cat = "<a href='walkth.php?refid=walk'>Click here to go to the walkthrough";
}
$query = mysql_query("SELECT * FROM posts WHERE category = $cat");
Correct Method :
if (isset($_GET['cat'])) {
$cat = $_GET['cat'];
} else {
$cat = "<a href='walkth.php?refid=walk'>Click here to go to the walkthrough"; //// Please remove this line it is creating problem.. when it does not find $_GET['cat']
} $query = mysql_query("SELECT * FROM posts WHERE category = $_GET['cat']");
You will still have a problem with the while loop if $_GET['cat'] isn't set because it won't know what that is. I would add an if statement to it to make sure that you won't get that error if $_GET['cat'] isn't set, I've added it above, this script should do what you need it to.