Display cross icon with message

hi all

The below code checks whether user already exists or not and echo the message accordingly

I m having trouble displaying a cross icon image with message if user already exists.

otherwise i dont want to show any message or may be remove message holder.

If i use insert image then the error i get is “undefined.”

otherwise message is displayed fine.

vineet


<?
$count = mysql_num_rows(mysql_query("SELECT * FROM usertable WHERE `username`='".$username."'")); 
        header('Content-Type: text/xml'); 
        header('Pragma: no-cache'); 
        echo '<?xml version="1.0" encoding="UTF-8"?>'; 
        echo '<result>'; 
        if($count > 0) { 
            echo 'Sorry! This username already exists.'; /* this displays message fine */
			
			echo '<img src="images/cross_small.gif" alt="" />Sorry! This Login-ID already exists.'; 
			/* But if i use image then message is displayed as "undefined"*/
        }else{ 
            echo '.';  
        } 
        echo '</result>'; 
		?>

this is message display holder


<span id="userlogin_error"></span>

this is ajax script


if(handle.value.length > 0) { 
        var fullurl = url + 'do=check_username_exists&username=' + encodeURIComponent(handle.value); 
        http.open("GET", fullurl, true); 
        http.send(null); 
        http.onreadystatechange = statechange_username; 
    }else{ 
        document.getElementById('userlogin_error').innerHTML = ''; 
    } 
} 

function statechange_username() { 
    if (http.readyState == 4) { 
        var xmlObj = http.responseXML; 
        var html = xmlObj.getElementsByTagName('result').item(0).firstChild.data; 
		document.getElementById('userlogin_error').innerHTML = html; 
		
    } 
} 

I’m thinking that you’re ending up with invalid xml when you put the <img> tag in there. That error seems to be saying that
xmlObj.getElementsByTagName(‘result’).item(0).firstChild.data
is undefined.

You’ll have to debug there. Check the result of each part. Is xmlObj.getElementsByTagName(‘result’) what you expect? etc.