PHP sending string to Javascript with a spaces cause error.

A

Anonymous

Guest
Ok.. here is the code:
I've Tried This (double Quote):
Code:
<a name="<?php echo $albumFolderArray ?>" 
onClick=goToSlideShow(name,"<?php echo $albumName ?>"); >

I've also Tried This (single Quote):
Code:
<a name="<?php echo $albumFolderArray ?>" 
onClick=goToSlideShow(name,'<?php echo $albumName ?>'); >


If $albumName has a space in it, i get an error.. otherwise i don't.
For example if
$albumName = "Hello world"; <-- This gives me unterminated string.
$albumName = "BLAH"; <-- This is ok.....
[/code]

Any IDEAS?? :?: :?: :?:
 
Your PHP looks fine, could the error be in your javascript?
 
Jay said:
Your PHP looks fine, could the error be in your javascript?

It is possible that the problem is in my javascript. but I have no idea how to fix.

:cry: :cry:
 
Well, if you wrote it yourself, then you can check it by insert alert() tags in various places. Unlike PHP (from version 4 onwards) the script will run until it fails. So if you get your alert, your script is fine up to that point.

If it's someone elses script, better get working hard on deciphering it ;)
 
Jay said:
Well, if you wrote it yourself, then you can check it by insert alert() tags in various places. Unlike PHP (from version 4 onwards) the script will run until it fails. So if you get your alert, your script is fine up to that point.

If it's someone elses script, better get working hard on deciphering it ;)

Actually it's my script but I solved it by using a function that replaced the quotes with a * and then when it is sent over to the next page, PHP replaces the * with a quote. Since the string is actually the name of a folder, I am sure i will never need to worry about having a folder name which has a deliberate * in it.

If anyone is interseted in seeing that code, just let me know.

Thanks!
 
Back
Top