I'm a little frustrated and I'm hoping someone can give me a hand.
I have a form element in which a user puts in names, seperated by hitting < return > on the keyboard.
These names are then split into an array so that I can query my database against them.
The problem I am having is that if there is more than one name in the list the only one that splits and works correctly for the query is the last name. The other names are all getting an extra space after the word.
I have tried using eregi_replace() to get rid of the space but that does not work either.
The odd thing is that I am using very similar split code elsewhere without problems.
When I look at the error it generates, it says it can not "jump to row 0" for the "mysql_result", however, I also tried pulling it out using "mysql_fetch_row" with no luck.
Here is the code I am using:
(the textarea field name is: related_members)
$pat = "\n"; //to separate at return
$member_array = split($pat, $related_members);
$total_related_members = count($member_array);
$count = 0;
while($count < $total_related_members)
{
$query = "select company from members where ";
$query .= "username=\"$member_array[$count]\"";
$result = @($query, $link);
$company = @mysql_result($result, 0, company);
print("$company" . ": ");
print("<a href=\"http://myserver.com/$member_array[$count]\">");
print("myserver.com/$member_array[$count]</a>");
print("<BR>");
$count++;
}
Any suggestions anyone has will be GREATLY appreciated!
Thanks.