Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Error that i'm over looking

Status
Not open for further replies.

NateBro

Programmer
Sep 1, 2004
233
US
i can't seem to get rid of the "\n" at the end of each $users_online[$i] its valve would be the same as "Nate_Bro\n" so i tried to use chomp($users_online[$i]); it didn't work, so i tried some other stuff too, i know its probably something really simple that i'm over looking.


Code:
for ($i = 0; $i <= $#users_online; $i++){

$thing = "$users_online[$i]";

chomp($thing);

print "	&nbsp;<a href=\"javascript:\" onclick=\"JavaScript:window.open('[URL unfurl="true"]http://s101571840.onlinehome.us/mss/cgi-bin/MB/register.cgi?rHy2=pro&name=$thing','profile','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=590,height=425')\"><font[/URL] color=\"#CCCCCC\">$thing</font></a>";

}

Thanks

~Nate_Bro
 
probably you created the file on windows and uploaded it to a nix sever. The newlines are different and chomp may not work.

Try:

$thing =~ s/\r\n$//;

and see if that helps.
 
thanks, but thats not working ether.....

i wonder if there is a way to have a multi line var in javascript?

I'll go look.

 
ok i got it working,

thanks sooooo much for your help and time!


~Nate_Bro
 
Nate,

What did you do to get it working, just for people coming after. Nothing worse than finding a thread that looks like it'll answer your question, and then doesn't

Cheers
--Paul

cigless ...
 
ya i was going to post how i did it, but anyways here it is...

for ($i = 0; $i <= $#users_online; $i++){

chomp(users_online[$i]);

## I just added the ' to the end
## and removed it from the javascript
$thing = "$users_online[$i]'";


print " &nbsp;<a href=\"javascript:\" onclick=\"JavaScript:window.open(' color=\"#CCCCCC\">$thing</font></a>";

}
 
hmmm.... that is really no different than what you were doing before, I don't see how that cured the problem. There is no need to use the variable $thing (that I can see), just use $user_online[$i] in your javascript output. Why create a new variable just to print it when you already have a variable with the value you want?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top