FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem with quotes in javascript output
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Problem with quotes in javascript output [message #181549 is a reply to message #181527] Tue, 21 May 2013 10:47 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Mon, 20 May 2013 12:17:26 -0400, richard wrote:

> This is not a javascript question ok?

Actually it is, because the problem seems to be that you're producing
invalid javascipt.

> The problem mainly deals with required quotes in the javascript output.
> Either single or double.

I don't think it does, although I suspect they may be an issue.

As far as I can tell, the final argument to jwplayer("my-video").setup()
looks like this (I've added some spaces for readability):

{ playlist : [ { { file : "http://www.youtube.com/watch?v=$vid[2]",
description : "$year # $number - $vid[1]" } ], "startparam" : "start",
"repeat" : "list", "width" : 800, listbar : { position : 'right', size :
320}, "height" : 450 }

There are several things here that might cause problems:

1) Mismatched brackets. You don't have the same number of all of (, { and
[ as you do respectively of ), } and ]. This is probably breaking the
javascript.

2) Some attributes are quoted and others are not. Although javascript is
fairly tolerant as to which quotes you use in that it generally treats
single and double quoted strings identically, I suspect that either you
should be passing either strings for all the attributes, or names for all
the attributes, but not a mixture of strings and names. For example,
playlist, file, description, listbar, position and size are names; and
"startparam", "repeat", "width" and "height" are strings. This may be
breaking the javascript.

3) Your php variable substitution isn't going to work for two reasons.
You need something more like:

echo "file: 'http://www.youtube.com/watch?v={$vid[2]}'";
echo ",";
echo "description: '$year # $number - {$vid[1]}'";

or

echo "file: \"http://www.youtube.com/watch?v={$vid[2]}\"";
echo ",";
echo "description: \"$year # $number - {$vid[1]}\"";

This is to address that (a) php variable substitution only works in
double quoted strings (ie when using "" and not ''), and (b) you should
wrap constructs of $array[element] with {} when using variable
substitution. This is probably causing the data passed to the javascript
to not be what you think it's getting.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: comma placement problem
Next Topic: no date header in mail()
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 18:32:09 GMT 2024

Total time taken to generate the page: 0.11448 seconds