values won't transfer [message #183663] |
Thu, 07 November 2013 18:06 |
Mr Oldies
Messages: 241 Registered: October 2013
Karma: 0
|
Senior Member |
|
|
www.mroldies.net/index.php
this is not the same page as the home page as that is still active for the
moment.
I am trying to pass the value in the url to the iframe.
No matter what I try, it won't.
I had to use the \" in order for the link to show properly.
The iframe is named "show".
My thinking is that the javascript has somehow destroyed that.
Queswtion is, how do I make it work so that the value "tune" will pass
properly?
<div style="float:left; width:5in; height:6in; overflow:auto;
border:solid 2px #00ff00; padding:10px;">
<ol>
<?php
$numbers=range(1,200);
shuffle($numbers);
foreach($numbers as $play) {
$htp="http://mroldies.net/index.php?tune=".$play." target=\"show\"";
echo "<li>";
$asong=$playme[$play][4];
echo "<a class='aplay' href='".$htp."'
data-src='http://mroldies.net/200/";
echo $asong;
echo ".mp3'>";
echo $playme[$play][2]." - ".$playme[$play][0]." #
".$playme[$play][1];
echo "<br>";
echo $playme[$play][3];
echo "</a>";
echo "</li>\n";
}
?>
</ol>
</div>
|
|
|
Re: values won't transfer [message #183664 is a reply to message #183663] |
Thu, 07 November 2013 18:56 |
Tim Streater
Messages: 328 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
In article <e2vbaluuftp4$(dot)48nrw7i8j930(dot)dlg(at)40tude(dot)net>, richard
<noreply(at)example(dot)com> wrote:
> www.mroldies.net/index.php
>
> this is not the same page as the home page as that is still active for the
> moment.
But you reference that in your code below. So that is what will be
used, not some other version.
> I am trying to pass the value in the url to the iframe.
> No matter what I try, it won't.
> I had to use the \" in order for the link to show properly.
> The iframe is named "show".
>
> My thinking is that the javascript has somehow destroyed that.
What javascript? You haven't shown any.
> Question is, how do I make it work so that the value "tune" will pass
> properly?
>
>
>
>
>
>
> <div style="float:left; width:5in; height:6in; overflow:auto;
> border:solid 2px #00ff00; padding:10px;">
> <ol>
> <?php
> $numbers=range(1,200);
> shuffle($numbers);
>
> foreach($numbers as $play) {
>
> $htp="http://mroldies.net/index.php?tune=".$play." target=\"show\"";
>
> echo "<li>";
> $asong=$playme[$play][4];
> echo "<a class='aplay' href='".$htp."'
> data-src='http://mroldies.net/200/";
> echo $asong;
> echo ".mp3'>";
> echo $playme[$play][2]." - ".$playme[$play][0]." #
> ".$playme[$play][1];
> echo "<br>";
> echo $playme[$play][3];
> echo "</a>";
>
> echo "</li>\n";
> }
>
> ?>
> </ol>
> </div>
Is the above part of your new mroldies.net file? If so, why are you
loading another copy of it into an iframe within it? And otherwise,
what are you doing inside the iframe to try to obtain the value of
tune?
The above didn't load anything into the iframe when I tried it; I
haven't looked into why. Personally I use open(), write(), and close()
to write an html string into an iframe, which may not be the best way
to do it but works well enough for me.
--
Tim
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
|
|
|
Re: values won't transfer [message #183665 is a reply to message #183663] |
Thu, 07 November 2013 19:58 |
Ben Bacarisse
Messages: 82 Registered: November 2013
Karma: 0
|
Member |
|
|
richard <noreply(at)example(dot)com> writes:
<snip>
> I am trying to pass the value in the url to the iframe.
> No matter what I try, it won't.
> I had to use the \" in order for the link to show properly.
> The iframe is named "show".
You quoting is wrong. In general, if you don't know exactly why you
needed some construct such as the \", it's better to go a read up on
that area. It's almost impossible to program by trial and error.
> My thinking is that the javascript has somehow destroyed that.
I think your question is purely a PHP one, so I've set followups
accordingly.
> Queswtion is, how do I make it work so that the value "tune" will pass
> properly?
<snip>
> $htp="http://mroldies.net/index.php?tune=".$play." target=\"show\"";
<snip>
> echo "<a class='aplay' href='".$htp."'
<snip>
If $play is, say, 42, the result of this will be:
<a class='aplay' href='http://mroldies.net/index.php?tune=42 target="show"'
Can you see how the show attribute is incorrectly inside the
single-quoted href attribute?
--
Ben.
|
|
|
Re: values won't transfer [message #183667 is a reply to message #183665] |
Thu, 07 November 2013 20:37 |
Mr Oldies
Messages: 241 Registered: October 2013
Karma: 0
|
Senior Member |
|
|
On Thu, 07 Nov 2013 19:58:20 +0000, Ben Bacarisse wrote:
> richard <noreply(at)example(dot)com> writes:
> <snip>
>> I am trying to pass the value in the url to the iframe.
>> No matter what I try, it won't.
>> I had to use the \" in order for the link to show properly.
>> The iframe is named "show".
>
> You quoting is wrong. In general, if you don't know exactly why you
> needed some construct such as the \", it's better to go a read up on
> that area. It's almost impossible to program by trial and error.
>
>> My thinking is that the javascript has somehow destroyed that.
>
> I think your question is purely a PHP one, so I've set followups
> accordingly.
>
>> Queswtion is, how do I make it work so that the value "tune" will pass
>> properly?
> <snip>
>> $htp="http://mroldies.net/index.php?tune=".$play." target=\"show\"";
> <snip>
>> echo "<a class='aplay' href='".$htp."'
> <snip>
>
> If $play is, say, 42, the result of this will be:
>
> <a class='aplay' href='http://mroldies.net/index.php?tune=42 target="show"'
>
> Can you see how the show attribute is incorrectly inside the
> single-quoted href attribute?
Thanks for the fresh eyes.
I had overlooked the closing quote and couldn't understand why
target="show" was showing up in the url.
Now I do.
|
|
|
Re: values won't transfer [message #183669 is a reply to message #183663] |
Thu, 07 November 2013 21:01 |
Arno Welzel
Messages: 317 Registered: October 2011
Karma: 0
|
Senior Member |
|
|
richard, 2013-11-07 19:06:
>
> www.mroldies.net/index.php
>
> this is not the same page as the home page as that is still active for the
> moment.
>
> I am trying to pass the value in the url to the iframe.
> No matter what I try, it won't.
> I had to use the \" in order for the link to show properly.
Yes - because the string is already delimited with double quotes.
> The iframe is named "show".
>
> My thinking is that the javascript has somehow destroyed that.
What JavaScript? There is no JavaScript in the code you present here.
> Queswtion is, how do I make it work so that the value "tune" will pass
> properly?
Don't put target="show" inside the href attribute. Check the created
HTML - you will hopefully see the error.
You define $htp as:
$htp="http://mroldies.net/index.php?tune=".$play." target=\"show\"";
But then you write:
echo "<a class='aplay' href='".$htp."' ...
So - expand this - it will become:
<a class='aplay'
href='http://mroldies.net/index.php?tune=$play target="show"'
Try to think about the problem - step by step. And not just put together
a bunch of code without caring for details!
If you put just the anchor attributes line by line the code also becomes
much easier to read. Also note that you can enclose double quotes in
single quotes (and vice versa) and there is absolutely no need to define
a separate variable to use an array value.
And finally: Either you have to make sure, that $playme[$play][3] does
not contain any "HTML stuff" or use htmlspecialchars() to encode/escape
special characters so they will be displayed properly.
Here a proposal how it should work (not checked - there may be typos):
<?php
foreach($numbers as $play) {
echo '<li>';
echo '<a';
echo ' class="aplay"';
echo ' href="http://mroldies.net/index.php?tune='.$play.'"';
echo ' target="show"';
echo ' data-src="http://mroldies.net/200/'.$playme[$play][4];
echo '">';
echo htmlspecialchars($playme[$play][3]);
echo '</a>';
echo '</li>';
}
?>
F'Up to comp.lang.php since this has nothing to do with JavaScript at all.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
|
|
|
Re: values won't transfer [message #183670 is a reply to message #183669] |
Thu, 07 November 2013 21:29 |
Mr Oldies
Messages: 241 Registered: October 2013
Karma: 0
|
Senior Member |
|
|
On Thu, 07 Nov 2013 22:01:10 +0100, Arno Welzel wrote:
> richard, 2013-11-07 19:06:
>
>>
>> www.mroldies.net/index.php
>>
>> this is not the same page as the home page as that is still active for the
>> moment.
>>
>> I am trying to pass the value in the url to the iframe.
>> No matter what I try, it won't.
>> I had to use the \" in order for the link to show properly.
>
> Yes - because the string is already delimited with double quotes.
>
>> The iframe is named "show".
>>
>> My thinking is that the javascript has somehow destroyed that.
>
> What JavaScript? There is no JavaScript in the code you present here.
>
>> Queswtion is, how do I make it work so that the value "tune" will pass
>> properly?
>
> Don't put target="show" inside the href attribute. Check the created
> HTML - you will hopefully see the error.
>
> You define $htp as:
>
> $htp="http://mroldies.net/index.php?tune=".$play." target=\"show\"";
>
> But then you write:
>
> echo "<a class='aplay' href='".$htp."' ...
>
> So - expand this - it will become:
>
> <a class='aplay'
> href='http://mroldies.net/index.php?tune=$play target="show"'
>
> Try to think about the problem - step by step. And not just put together
> a bunch of code without caring for details!
>
> If you put just the anchor attributes line by line the code also becomes
> much easier to read. Also note that you can enclose double quotes in
> single quotes (and vice versa) and there is absolutely no need to define
> a separate variable to use an array value.
>
> And finally: Either you have to make sure, that $playme[$play][3] does
> not contain any "HTML stuff" or use htmlspecialchars() to encode/escape
> special characters so they will be displayed properly.
>
> Here a proposal how it should work (not checked - there may be typos):
>
> <?php
> foreach($numbers as $play) {
> echo '<li>';
> echo '<a';
> echo ' class="aplay"';
> echo ' href="http://mroldies.net/index.php?tune='.$play.'"';
> echo ' target="show"';
> echo ' data-src="http://mroldies.net/200/'.$playme[$play][4];
> echo '">';
> echo htmlspecialchars($playme[$play][3]);
> echo '</a>';
> echo '</li>';
> }
> ?>
>
> F'Up to comp.lang.php since this has nothing to do with JavaScript at all.
If you'd bother to note I cross posted this for that reason.
Thanks.
But it still won't transfer.
|
|
|
Re: values won't transfer [message #183672 is a reply to message #183670] |
Fri, 08 November 2013 07:33 |
Arno Welzel
Messages: 317 Registered: October 2011
Karma: 0
|
Senior Member |
|
|
richard, 2013-11-07 22:29:
> On Thu, 07 Nov 2013 22:01:10 +0100, Arno Welzel wrote:
>
[Building a list of links with a frame as target]
>> And finally: Either you have to make sure, that $playme[$play][3] does
>> not contain any "HTML stuff" or use htmlspecialchars() to encode/escape
>> special characters so they will be displayed properly.
>>
>> Here a proposal how it should work (not checked - there may be typos):
>>
>> <?php
>> foreach($numbers as $play) {
>> echo '<li>';
>> echo '<a';
>> echo ' class="aplay"';
>> echo ' href="http://mroldies.net/index.php?tune='.$play.'"';
>> echo ' target="show"';
>> echo ' data-src="http://mroldies.net/200/'.$playme[$play][4];
>> echo '">';
>> echo htmlspecialchars($playme[$play][3]);
>> echo '</a>';
>> echo '</li>';
>> }
>> ?>
>>
>> F'Up to comp.lang.php since this has nothing to do with JavaScript at all.
>
> If you'd bother to note I cross posted this for that reason.
What reason? Please explain. Your code did not contain any JavaScript.
> Thanks.
> But it still won't transfer.
Please define "transfer". What is missing?
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
|
|
|