Jump to content


Photo

Small problem, Not outputting. *SOLVED*


  • Please log in to reply
4 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 24 September 2006 - 09:26 PM

Hio,
I'm having a small problem with PHP, he seems to be getting
on my nerves tonight, well the thing is I have a avatar for
my members, yet I wanted to check if they ahve an avatar
or give them the default avatar.

So I check mysql as you do, and PHP doesn't seem to output
anything :/ could someone check my code, thx.

<?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>


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 September 2006 - 09:34 PM

If there is no data found, code inside the while loop is not executed
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 24 September 2006 - 09:46 PM

How could i fix it?

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 September 2006 - 09:50 PM

<?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>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 24 September 2006 - 09:53 PM

worked. thanks :]. just confused me! thanks again.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users