PHP sending string to Javascript with a spaces cause error.

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

PHP sending string to Javascript with a spaces cause error.

Postby imroue » Sat Oct 26, 2002 6:47 pm

Ok.. here is the code:
I've Tried This (double Quote):

Code: Select all

<a name="<?php echo $albumFolderArray ?>"
onClick=goToSlideShow(name,"<?php echo $albumName ?>"); >


I've also Tried This (single Quote):

Code: Select all

<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?? :?: :?: :?:

Jay

Postby Jay » Sun Oct 27, 2002 2:24 am

Your PHP looks fine, could the error be in your javascript?

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

Postby imroue » Sun Oct 27, 2002 9:13 am

Jay wrote: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:

Jay

Postby Jay » Sun Oct 27, 2002 3:08 pm

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 ;)

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

Postby imroue » Wed Oct 30, 2002 7:02 pm

Jay wrote: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!


Return to “PHP coding => General”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest