K3nnnn Posted March 9, 2007 Share Posted March 9, 2007 i want to fetch a value from my user database table for the current logged in user. Then using the conditions, if $X equals 0 echo the default avatar location, else get the location from avatar_loc field and echo the avatar. heres what ive come up with: /* Avatar */ echo "<img src='../../../img/icons/avatar_icon.png' /> "; echo " <b>Avatar:</b>"; require_once('includes/DbConnector.php'); $connector = new DbConnector(); // Execute the query to find if user has an avatar, echo uploaded avatar if there is one in DB, if not load default. $result = $connector->query('SELECT avatar, FROM users WHERE ID = $session->username '); echo $result; if ($result==1){ echo "test works"; } else echo " <img src='../../../img/icons/default_avitar.gif' width='32' height='32' />"; im going wrong somewhere but i cant pin point it the output at the moment is the default avatar even ifthere is a 1 in the avatar field thanks for taking time to read this Link to comment https://forums.phpfreaks.com/topic/41943-using-ifelse-statments-to-fetch-avatar-from-mysql-db/ Share on other sites More sharing options...
JasonLewis Posted March 9, 2007 Share Posted March 9, 2007 is $result echoing 1 when it should be? Link to comment https://forums.phpfreaks.com/topic/41943-using-ifelse-statments-to-fetch-avatar-from-mysql-db/#findComment-203372 Share on other sites More sharing options...
K3nnnn Posted March 9, 2007 Author Share Posted March 9, 2007 no it isnt, so i dont think the problem is in the logic, as it isnt echoing any thing from $result im thinking my query is wrong maybe?? Link to comment https://forums.phpfreaks.com/topic/41943-using-ifelse-statments-to-fetch-avatar-from-mysql-db/#findComment-203432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.