HighDots Forums  

How do you escape an = in PHP?

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss How do you escape an = in PHP? in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DavidB
 
Posts: n/a

Default How do you escape an = in PHP? - 11-05-2005 , 04:39 AM






I get an "unexpected =" error message from this script. It apparently
has nothing to do with a href=, but is triggerred by one more of the
following = signs. How do you fix this kind of parse error? Thanks.

echo 'See a complete list: <a href=\"javascript:;\"
onclick=\"MM_openBrWindow('/a1/inc/scripts/ecoregions.php?Animal=".$GZAnimals['Name2']."
&amp;Rank=".$GZAnimals['Rank']."','JBNations','scrollbars=yes,resizable=yes,widt h=400,height=250')>Pop-Up</a>';

Reply With Quote
  #2  
Old   
David Powers
 
Posts: n/a

Default Re: How do you escape an = in PHP? - 11-05-2005 , 05:06 AM






DavidB wrote:
Quote:
I get an "unexpected =" error message from this script. It apparently
has nothing to do with a href=, but is triggerred by one more of the
following = signs. How do you fix this kind of parse error? Thanks.
By fixing your quotes correctly:

echo 'See a complete list: <a href="javascript:;"
onclick="MM_openBrWindow(\'/a1/inc/scripts/ecoregions.php?Animal='.$GZAnimals['Name2'].'
&amp;Rank='.$GZAnimals['Rank'].'\',\'JBNations\',\'scrollbars=yes,resizable=yes, width=400,height=250\'")>Pop-Up</a>';

Actually, you're misusing PHP to echo all that straight HTML. It would
be far more efficient, and less prone to error to use PHP to echo only
those parts of the script that change.

See a complete list: <a href="javascript:;"
onclick="MM_openBrWindow('/a1/inc/scripts/ecoregions.php?Animal=<?php
echo $GZAnimals['Name2']; ?>
&amp;Rank=<?php echo $GZAnimals['Rank'];
?>','JBNations','scrollbars=yes,resizable=yes,widt h=400,height=250'")>Pop-Up</a>';

--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (foED - forthcoming)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://computerbookshelf.com


Reply With Quote
  #3  
Old   
DavidB
 
Posts: n/a

Default Re: How do you escape an = in PHP? - 11-05-2005 , 05:35 AM



David Powers wrote:

Quote:
DavidB wrote:

I get an "unexpected =" error message from this script. It apparently
has nothing to do with a href=, but is triggerred by one more of the
following = signs. How do you fix this kind of parse error? Thanks.


By fixing your quotes correctly:
Thanks. I was using the html version in the beginning, but I wanted to
use it in a PHP switch, so I thought I had to echo it. However, your
comments jogged my memory, and I simply inserted a ?> before the links
and <?php after them.

Thanks for the tips.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.