Getting this query to work with xenforo code

Member 3639

Active member
Basically i have this code
$db = XenForo_Application::get('db');
while ($category = $db->fetchAll("SELECT * FROM `articles_category` ORDER BY `category_name` ASC"))
    $mydata .= $category['category_name'];
Which gives me an error of;
ErrorException: Undefined index: category_name - library/EWRporta/Block/MyPhp/myfile.php:8

What is the best way to "define" it?

Mike Tougeron

Well-known member
That's basically saying that the field 'category_name' doesn't exist in the result. Have you tried doing a var_dump($category); to see what that holds?