Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP sending string to Javascript with a spaces cause error.

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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?? :?: :?: :?:
User avatar
imroue
New php-forum User
New php-forum User
 
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am

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

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

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:
User avatar
imroue
New php-forum User
New php-forum User
 
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am

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

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!
User avatar
imroue
New php-forum User
New php-forum User
 
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.