Reputation: 5442
i got this thing
<?
if (mysql_num_rows($say) == 1) {
$a = "cicişsin!";
}
elseif (mysql_num_rows($say) == 0) {
$a = "<a href='javascript:LaunchPopup('a2.php','250','1');'>ciciş yap</a>";
}
?>
but i cant echo second $a.. its exits at "javascript:LaunchPopup(" single quotes not shown
what can i do?
Upvotes: 5
Views: 2828
Reputation: 536715
Never use javascript:
URLs. Put the URL in the href
attribute where it belongs:
$a= '<a href="a2.php" onclick="LaunchPopup(this.href, 250, 1); return false;">ciciş yap</a>';
Now not only do you not have to worry about the escaping (assuming you can get away with passing numbers as the other arguments), but also your link now works properly when middle-clicked or bookmarked, instead of giving a JavaScript error.
Better still, unobtrusive scripting:
<a href="a2.php" class="popup">ciciş yap</a>
<script type="text/javascript">
for (var i= document.links.length; i-->0;) {
if (document.links[i].className==='popup') {
document.links[i].onclick= function() {
LaunchPopup(this.href, '250', '1');
return false;
}
}
}
</a>
Keep script code in scripts and out of markup, then you don't have to worry about HTML-escaping.
Upvotes: 3
Reputation: 16244
$a = "<a href='javascript:LaunchPopup(a2.php,250,1)'>ciciş yap</a>";
will work for you
Upvotes: -3
Reputation: 3185
Escape the quotes like this
"<a href=\"javascript:LaunchPopup(\'a2.php\',\'250\',\'1\');\">ciciş yap</a>"
Upvotes: 1
Reputation: 1210
$a = "<a href=\"javascript:LaunchPopup('a2.php','250','1');\">ciciş yap</a>";
Upvotes: 11
Reputation: 5363
Use backslashes, something like this:
$a = "<a href='javascript:LaunchPopup(\"a2.php\",\"250\",\"1\");'>ciciş yap</a>";
Upvotes: 0