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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop<arguments.length; invalid character ?? help 1

Status
Not open for further replies.

girlinterrupted24

Programmer
Nov 16, 2005
35
ES
Hey guys...

I am getting this error

Un nombre contenía un carácter no válido. Error al procesar

Which I think means something like "The name contained a non-valid character"

for (var loop=0; loop<arguments.length; loop++) {
---------------------------------------^

What could cause this error -- helpppp

The whole code is :

function Refresher(pic1,pic2,pic3,pic4,pic5,pic6,pic7,pic8,pic9,pic10,pic11,pic12,pic13,pic14,pic15,pic16,pic17,pic18,pic19,pic20) {

for (var loop=0; loop<arguments.length; loop++) {
if (arguments[loop] != '') {
// document.images['pic' + (loop+1)].src = '../images/property' + arguments[loop] + '?randomParam=' + new Date().getTime();
document.images['pic' + (loop+1)].src = '../images/property' + arguments[loop] + '?' + new Date().getTime();
}
}
}

Your help would be so much appreciated... this error only happens very rarely tooo...... So I dont know what throws it!!
 
The whole code is

If that's the whole code, I'd be worried. There's no associated HTML, and you don't call the function anywhere.

Can you post a URL to the whole code?

The only thing I can think of from looking at the "whole" code you've given is that if there are less images on the pgae than arguments being passed, you'll probably get an error.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Sorry about that... maybe I was unclear!!!! That is just the Javascript code where the error is coming from... it is being called, and there is all the page html below, etc :)

Anyway thank you so much for your help. In response to your question, well...... basically it only refreshes the Img SRC IF the variable is NOT empty - so that should hopefully not error? Should I maybe set a if it is Null checker too ?

AND the weird thing is it IS working 95% of the time! Which is what i throwing me..... What throws it the other 5% of the time!

ALSO another point is - Hmm yeah could mean something to you - Basically the page is a form where you input information, then there is a Window Pop Up to Upload Photos. This function is called when you close a window upload pop up box, to refresh the image src on the main form page... BUT the error only seems to be thrown when the user SAVES the whole form on the original page - NOT when the function is physically being called after the upload... ? Does this help you?

Many thanks again
 
BUT the error only seems to be thrown when the user SAVES the whole form on the original page - NOT when the function is physically being called after the upload... ? Does this help you?

That could well be the problem. If I understand correctly, when the user closes the "upload photo" window, the main page is refreshed to show the changes. However, if the window is not closed, the main page will not update, and so something it (the JS routine) is expecting to find, it cannot.

However, one question that nags at me is - why is the page expecting anything different if it hasn't been refreshed (and thus know anything about the new image)? Are you setting or changing any variables, or running any code, when you open the popup? Or maybe using "opener" at any time in the popup outside of the code you call when you close it?

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks so much for replying

In response to your question - basically when the User closes the Upload photo window - this calls the funtion on the parent page

<a href="javascript:window.opener.Refresher('<%= var_js1 %>','<%= var_js2 %>','<%= var_js3 %>','<%= var_js4 %>','<%= var_js5 %>','<%= var_js6 %>','<%= var_js7 %>','<%= var_js8 %>','<%= var_js9 %>','<%= var_js10 %>','<%= var_js11 %>','<%= var_js12 %>','<%= var_js13 %>','<%= var_js14 %>','<%= var_js15 %>','<%= var_js16 %>','<%= var_js17 %>','<%= var_js18 %>','<%= var_js19 %>','<%= var_js20 %>');self.close();">Close window</a>

And yes what this does is updates the image SRC's of the photos which have now been uploaded.

If you save no photos at all - so basically the function never gets called, it then does not error on the saving of the form. I cannot get it to error no matter what I do - so I dont know what is causing it when this user does it. And other people have used it and it has not hit an error either... so very weird.

So I was thinking maybe if I put EXTRA error checking on the Javascript... just IN CASE of any eventuality... then maybe this would stop it?

This is where I am lost though, as my idea would be maybe to check to ensure there are items in the arguments.length ? Then aswell as check this if (arguments[loop] != '') { maybe also check for Null or Empty ?

Again just ideas... what do you think?

I am sorry to bother you with this... Thank you
 
Sorry... just a few more thoughts...

IF you upload less than 20 pictures - lets say you have uploaded 3 the funtion should then have basically :

Refresher('image location 1','image location 2','image location 3','','','','', ... and so on up to 20)

So then on the function checker

if (arguments[loop] != '') {

This should catch all errors - so I dont know at all where the error can be coming from :(

Your help is so much appreciated with this... as Im a bit.. .well a lot... lost with what the problem is... and like i say it is happened very infrequently - and I cannot even get it to happen for me.......

thanks again
 
Hi Dan,

Well.... I have the system on my local testing server, and basically the running system is currently in use and is logged as to which user is logged in and it would be testing on a live site which is not good...

Soooo I have zipped the files in question and uploaded them to one of my sites so you can then just download them and have a peak...

This is the link :
Thanks so much again for your help with this
 
I have got it uploaded to some space I know wont be used over the weekend :)

Basically I have placed the Add Property / Photo files, basically just go here :


User : tonya
pass : test

Once you are in just go to Add property - and there you will see it all in action :) I have just added one in there quick now to make sure it is all ok... and it is. Like I say NO MATTER what i do i cannot get it to error :( but fact is on SOME LITTLE thing it is erroring, even if just 5% of the times a property is addded. Over 200 properties + have been added... and basically I woudl say out of those 200+ times the error has happened only 5 - 10 times...?

Thanks so much again - as im lost :(!!
 
Well - I can't seem to get the error at all. Could you try and narrow down the circumstances under which it happens?

On a different note, the trusty Firefox JS console did show up 3 errors in your "control_panel.css" file:

On line 84, you have "font-weight: 14px;" - shouldn't this be font-size? You cannot specify a pixel value for a font weight, AFAIK.

On line 1285, you have "padding: 15px 15px 15px 15xp;". "xp" is not a valid unit. You can use just "padding: 15px;" to do what you're after.

On line 1409, you have "color: 505050;" - you need to insert a hash symbol before the colour values.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thank you so much for those tips!!! That is my rushing things!!!! Thank you so much!

The error!! I KNO - Isnt it crazy!!!!!!!! I CANNOT get it at all - I have tried so many things to try and get it and cant!!

Basically it happens when a user has added all their information in the form boxes, uploaded some photos... the exact number of photos i am unsure... but basically they are adding some - so it would be anything from 1 to the maximum for the site which is 7.

And yes - it throws that error up when they go to SAVE the Property on the Form - NOT when they are actually saving the pictures.....

Other points is the little picture thumbnails update for them after upload which is all correct... So it is not that Javascript is disabled on their machine or anything... I also then asked them to add a property while I was on the telephone - using the same machine as they were before, and it added fine - SO it also is NOT happening to them ALL the time, just on a certain occasion which I just do not know!!!

The error would appear to definitely be coming from the photo javascript as thankfully I managed to get her to send me that error message I included for you at the top, but I am including it again below... sadly in Spanish but it says yeah .. something like invalid character...

No se puede mostrar la página XML
No se puede ver la entrada XML con la hoja de estilo XSL. Corrija el error y haga clic en el botón Actualizar, o inténtelo de nuevo más tarde.


--------------------------------------------------------------------------------

Un nombre contenía un carácter no válido. Error al procesar el recurso file:///C:/Documents and Settings/Server/Escritorio/...

for (var loop=0; loop<arguments.length; loop++) {
---------------------------------------^

Is there maybe any extra error checking I can put on that javascript which would catch whatever that is... And WHY is it finding it on Save the Property as the Function is not being called then anyway.... ?

Thank you so so much once again - so much appreciated
 
another thing: you are susceptible to sql-injection attacks. i was able to login to both

and

using
Code:
' or ''='

as the username and password.

you can fix this simply by stripping or escaping single quotes

google "sql injection"

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Hmm - this should fix your problem, regardless of the browser they are using. It implements arguments.length if it is not natively supported:

Code:
if (typeof(arguments.length) == 'undefined') {
	var argCount = 0;
	while (typeof(arguments[argCount]) != 'undefined') argCount++;
	arguments.length = argCount;
}

Just place it right before this line:

Code:
for (var loop=0; loop<arguments.length; loop++) {

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
WOW to both of you!!!!!!!!!!

OK main problem first even other one is worrying!! Oooopppsss.....

WELL that could totally be the case!!! That would make sense wouldn't it....... As I can never get the error - nor can you, and the code doesn't look wrong at all!!

So 2 things..... what do i do if they are using an older version... is there an alternative ... AHHH actually what would be ideal IS ... basically this code is ONLY for display purposes..... so it would never stop the photos actually saving, etc. So is there any form of SUPER error check or somethign that I could add to the little function - just so that people who cannot run it - at least it will just override it? Hmm you may have a better suggestion :)

I must say tho could be the only thing couldn't it?? I mean you have seen all the code and tested it - and it all seems fine. I cant get the error ever either... ? So yeah I hope so anyway :)))

Other security point - GODDDDDD I never knew this... self taught :(

So what do I need to do, make sure no passwords ever contain ' or '' ? And then on login before it queries the table... basically make sure these are stripped out?

Thank you so so much again for all your continued help with this Dan - I would never have know what it was!! and also thank you for pointing that major flaw out Jeff.
 
like this :)

function Refresher(pic1,pic2,pic3,pic4,pic5,pic6,pic7,pic8,pic9,pic10,pic11,pic12,pic13,pic14,pic15,pic16,pic17,pic18,pic19,pic20) {

if (typeof(arguments.length) == 'undefined') {
var argCount = 0;
while (typeof(arguments[argCount]) != 'undefined') argCount++;
arguments.length = argCount;
}

for (var loop=0; loop<arguments.length; loop++) {
if (arguments[loop] != '') {
// document.images['pic' + (loop+1)].src = '../images/property' + arguments[loop] + '?randomParam=' + new Date().getTime();
document.images['pic' + (loop+1)].src = '../images/property' + arguments[loop] + '?' + new Date().getTime();
}
}
}
 
Yeah - that is a good idea!! Like I say I would certainly never ever have known what it was without your help!! And yes it could have proven to be a VERY bizarre problem I would have kept testing and never knowing what was causing it!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top