Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Mysqli/php code issue

Hello everyone,

I dont understanding why this one isnt working. I have one latterly the exact same code just different var. Could someone

This one is returning

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/afmccombs/public_html/includes/template_status.php on line 57

<?php
$queryrav = mysqli_query($mysqli, "SELECT avatar WHERE username = '$replyauthor' AND activated = '1'");
$row_reply_avatar = mysqli_fetch_array($queryrav, MYSQLI_ASSOC);
$reply_avatar = $row_reply_avatar["avatar"];
?>

This is the one that works

<?php
$sqlav = "SELECT avatar FROM users WHERE username = '$author' AND activated = '1'";
$queryav = mysqli_query($mysqli, $sqlav);
$rowavatar = mysqli_fetch_array($queryav, MYSQLI_ASSOC);
$account_avatar = $rowavatar["avatar"];
?>

2 Answers

Hi Andrew,

In the first code example you are not specifying a table.

Jeff

you forget added the FROM of table.

Thank you