MDanz Posted February 13, 2010 Share Posted February 13, 2010 how do i say if user doesn't exist. that below shows the avatar correctly for the user posting. How do i do if the user doesn't exist from the database? $useravatar = mysql_query("SELECT * FROM Users WHERE username='$username1'")or die (mysql_error()); while($row5 = mysql_fetch_array($useravatar)){ $image = $row5['avatar']; } Link to comment https://forums.phpfreaks.com/topic/191931-help-with-if-statement/ Share on other sites More sharing options...
trq Posted February 13, 2010 Share Posted February 13, 2010 Your actual question makes little sense but you should always be checking you optained a record before using it anyway. eg; if ($result = mysql_query("SELECT avatar FROM Users WHERE username='$username1'") { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); $image = $row['avatar']; } else { // no record found. } } else { trigger_error(mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/191931-help-with-if-statement/#findComment-1011622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.