Page 1 of 3
stupid little syntax error - javascript and php
Posted: Mon Mar 22, 2004 9:55 pm
by John Cartwright
can't seem to get this to work :S
Code: Select all
<?php ?>
<a href="javascript:window.open("picture.php?<? echo "type=$type&picture=$picture&title=$title"; ?>", "Picture Viewer","toolbar=0,status=0,menubar=0,scrollbars=no,resizable=no");> <img src=" <? echo "portfolio/$type/$picture"; ?>" width="450" height="410" border="1"></a>
<? ?>
Is it a missing quote? what what what
lol ty.. sorry for this nub question just its making me so mad
Posted: Mon Mar 22, 2004 9:58 pm
by bawla
for one thing you don't have a semicolin[;] at the end of your lines
Posted: Mon Mar 22, 2004 9:58 pm
by andre_c
you have to add a semicolon
Code: Select all
<? echo "type=$type&picture=$picture&title=$title"; ?> //here
<? echo "portfolio/$type/$picture"; ?> // and here
Edited: Damn, I'm not quick enough

Posted: Mon Mar 22, 2004 10:00 pm
by John Cartwright
When I run the code and I check the link of the image it is only returning this:
javascript:window.open(
Posted: Mon Mar 22, 2004 10:01 pm
by andre_c
Does it work now???
Posted: Mon Mar 22, 2004 10:02 pm
by John Cartwright
no......... jus said it only returns
javascript:window.open(
Posted: Mon Mar 22, 2004 10:03 pm
by bawla
from wut i know of javascript
Code: Select all
<a href="javascript:window.open("picture.php?<? echo "type=$type&picture=$picture&title=$title"; ?>", "Picture Viewer","toolbar=0,status=0,menubar=0,scrollbars=no,resizable=no");>
has to be one line, please correct me if im wrong
Posted: Mon Mar 22, 2004 10:04 pm
by andre_c
instead of doing
try doing
.
Posted: Mon Mar 22, 2004 10:05 pm
by John Cartwright
bawla wrote:from wut i know of javascript
Code: Select all
<a href="javascript:window.open("picture.php?<? echo "type=$type&picture=$picture&title=$title"; ?>", "Picture Viewer","toolbar=0,status=0,menubar=0,scrollbars=no,resizable=no");>
has to be one line, please correct me if im wrong
It is 1 line... this textbox is just not large enough...
Andre: That isn't working either :S
Posted: Mon Mar 22, 2004 10:10 pm
by andre_c
Are you getting a php error, or a javascript error?
Posted: Mon Mar 22, 2004 10:11 pm
by bawla
i should have thought before i posted
Posted: Mon Mar 22, 2004 10:11 pm
by John Cartwright
andre_c wrote:Are you getting a php error, or a javascript error?
java..when the link is clicked
Posted: Mon Mar 22, 2004 10:12 pm
by m3mn0n
How about seperating each 'section' of that line into it's own variable and then echo the variables?
eg.
Code: Select all
<?php
$var1 = "<a href="";
$var2 = $varable_from_someplace;
$var3 = "" target="_top">clickme!</a>";
$display = $var1 . $var2 . $var3;
echo $display;
?>
It makes things a bit more simple, not to mention organized.
Posted: Mon Mar 22, 2004 10:15 pm
by John Cartwright
I don't think that would work.... from my experience I have never been able to input/output javascrjpt inside php.. I also had to escape it.. I wish it were as simple as setting the target to a new window :S
Posted: Mon Mar 22, 2004 10:18 pm
by andre_c
what does the error say? I would recommend trying one of these browser if you have one: Netscape, firefox, opera, or any that has a javascript console. That way you can get much more details on the errors.
... and sami is right, you can write javascript from php. I do it all the time. (you can't write php using javascript though, just making sure you know

)