xyn Posted September 24, 2006 Share Posted September 24, 2006 Hio,I'm having a small problem with PHP, he seems to be gettingon my nerves tonight, well the thing is I have a avatar formy members, yet I wanted to check if they ahve an avataror give them the default avatar.So I check mysql as you do, and PHP doesn't seem to outputanything :/ could someone check my code, thx.[code=php:0]<?PHP include("session.php"); $SQLB = mysql_query("SELECT filename FROM avatar WHERE user='{$_SESSION['username']['usr_user']}'"); while( $Data = mysql_fetch_array( $SQLB, MYSQL_NUM )){ $NUMB = mysql_num_rows( $SQLB ); if( !$NUMB ){ $avatar="avatar.PNG"; }else{ $avatar = $Data[0]; } }?><p>text here<br><img border="0" src="./global/images/private/<?PHP echo $avatar; ?>" alt="Avatar"></p>[/code] Link to comment https://forums.phpfreaks.com/topic/21892-small-problem-not-outputting-solved/ Share on other sites More sharing options...
Barand Posted September 24, 2006 Share Posted September 24, 2006 If there is no data found, code inside the while loop is not executed Link to comment https://forums.phpfreaks.com/topic/21892-small-problem-not-outputting-solved/#findComment-97770 Share on other sites More sharing options...
xyn Posted September 24, 2006 Author Share Posted September 24, 2006 How could i fix it? Link to comment https://forums.phpfreaks.com/topic/21892-small-problem-not-outputting-solved/#findComment-97776 Share on other sites More sharing options...
Barand Posted September 24, 2006 Share Posted September 24, 2006 [code]<?php include("session.php"); $SQLB = mysql_query("SELECT filename FROM avatar WHERE user='{$_SESSION['username']['usr_user']}'");$NUMB = mysql_num_rows( $SQLB );if( !$NUMB ){ $avatar="avatar.PNG";}else{ $Data = mysql_fetch_array( $SQLB, MYSQL_NUM ); $avatar = $Data[0];}?><p>text here<br><img border="0" src="./global/images/private/<?php echo $avatar; ?>" alt="Avatar"></p>[/code] Link to comment https://forums.phpfreaks.com/topic/21892-small-problem-not-outputting-solved/#findComment-97777 Share on other sites More sharing options...
xyn Posted September 24, 2006 Author Share Posted September 24, 2006 worked. thanks :]. just confused me! thanks again. Link to comment https://forums.phpfreaks.com/topic/21892-small-problem-not-outputting-solved/#findComment-97780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.