0

Hi all, is there any prblem with my array? why i can get the first element of the array

function GetNameByEmail($get_staffemail)
{	print_r($get_staffemail);
	for($i=0;$i<count($get_staffemail);$i++){		
		echo "<br />";
		echo $qryGetName = "SELECT username FROM user_info WHERE email ='".$get_staffemail[$i]."'";
		$rsGetName  = mysql_query($qryGetName);
		$arrGetName[$i] = mysql_fetch_array($rsGetName, MYSQL_ASSOC);
	}
	echo "<br />";
	print_r($arrGetName);
	return $arrGetName[glob_username];
}

here the result(output)
Array ( [0] => hehe@live.com.my [1] => haha@live.com.my )
SELECT username FROM user_info WHERE email ='hehe@live.com.my '
SELECT username FROM user_info WHERE email ='haha@live.com.my'
Array ( [0] => [1] => Array ( [glob_username] => haha ) )

anyone help pls T^T this is the last task and i got to hand up by tomorrow~

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

I think there is no row in your database with email id "hehe@live.com.my",
if it is there then change your line number 5 in above code with following line

echo $qryGetName = "SELECT username FROM user_info WHERE trim(email) =  trim('".$get_staffemail[$i]."') ";

Edited by urtrivedi: n/a

0

Is it possible yor first e-mail to be wrong? In the answer of the script first select query is:

SELECT username FROM user_info WHERE email ='hehe@live.com.my '

There is an blank space before '. Is that right?

0

I mean that e-mail don't have blank spaces and because of that you don't have user that response to 'hehe@live.com.my '. The solution of urtrivedi is good. Use it.

0

what is the name of the staffname field in table?
Are passing array to function?

Edited by vibhaJ: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.