There are lots of comments on how to fix the mysqli_error line, but there are two problems with the SQL itself:
- You are joining the
users_categories
table twice and not joining the users
table at all.
- The second ON is identical to the first, so it references the wrong columns in the wrong tables.
This should work better:
SELECT users.*, categories.*, users_categories.*
FROM users_categories
INNER JOIN users ON users_categories.user_id = users.user_id
INNER JOIN categories ON users_categories.category_id = categories.id
WHERE users_categories.user_id=3