pwesthead Posted May 14, 2012 Share Posted May 14, 2012 Hi i have a chat written in php and as3 at the moment the chat window shows username and message but i want to add a avatar before the username. here is the code i have. $sql = mysql_query("SELECT * FROM chat75 ORDER BY date_time ASC"); while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $user_name = $row["user_name"]; $chat_body = $row["chat_body"]; $num = $row["avatar"]; $date_time = $row["date_time"]; $chat_body = stripslashes($chat_body); $chat_body = eregi_replace("'", "'", $chat_body); $string =array(); $files = glob("../images/avs/*.*"); for ($i=1; $i<count($files); $i++) { $num = $files[$i]; } $body .= '<b><font color="#006699">' . $num . ': ' . $user_name . ': <font color="#000000"> ' . $chat_body . '</font> <br />'; } this is what i get in the chat window ../images/avs/avatar9.png: demo123: testing message i have tried everything to get the avatar to appear in the chat window but keep getting the above,i have tried to put echo in front but then just get a blank chat window. please help thanks Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/ Share on other sites More sharing options...
trq Posted May 14, 2012 Share Posted May 14, 2012 $body .= '<b><font color="#006699"><img src="' . $num . '">: ' . $user_name . ': Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345265 Share on other sites More sharing options...
pwesthead Posted May 14, 2012 Author Share Posted May 14, 2012 Hi i tried the code you put but just get a blank screen, iv tried eveything but no joy Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345267 Share on other sites More sharing options...
Lambneck Posted May 14, 2012 Share Posted May 14, 2012 $body = "<b><span style='color:#006699;'>" . $num . ": " . $user_name . ; also might want to double check the path to your image. Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345274 Share on other sites More sharing options...
pwesthead Posted May 14, 2012 Author Share Posted May 14, 2012 Hi thanks for your reply tried that code too no joy blank screen, the image directory is correct, this has got me pulling my hair out thought this would be easy but apparently not? thankspaul Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345286 Share on other sites More sharing options...
trq Posted May 14, 2012 Share Posted May 14, 2012 My code should work fine. What do you see when you view the source of the page? Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345288 Share on other sites More sharing options...
trq Posted May 14, 2012 Share Posted May 14, 2012 Actually, looking at it again, there would be an unclosed <font> tag. Fix that and you should be golden. Better still, don't use font tags, they are pretty 1995. Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345290 Share on other sites More sharing options...
pwesthead Posted May 14, 2012 Author Share Posted May 14, 2012 Hi no it does not work if i use this works fine but as soon as i add the avatar bit no joy $body .= '<b><font color="#006699"> ' . $user_name . ': <font color="#000000"> ' . $chat_body . '</font> <br />'; Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345295 Share on other sites More sharing options...
trq Posted May 14, 2012 Share Posted May 14, 2012 Did you read my last two replies? Quote Link to comment https://forums.phpfreaks.com/topic/262498-problem-with-avatar-in-chat-windo/#findComment-1345470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.