user2745422
user2745422

Reputation: 29

open a new pop-up window from a link when you click

echo "<a href="http://www.quackit.com/common/link_builder.cfm" onclick="basicPopup(this.href);return false">Open a popup window</a>";

I am new to PHP. I am currently having the following error:

Parse error: syntax error, unexpected 'http' (T_STRING), expecting ',' or ';' in search.php on line 91

I know its a syntax error, but I have tried many times, and still can't solve the problem.

Upvotes: 0

Views: 10918

Answers (3)

Janak Prajapati
Janak Prajapati

Reputation: 886

try this code

<?php

echo "<a href='http://www.quackit.com/common/link_builder.cfm' onclick='basicPopup(this.href);return false'>Open a popup window</a>";

?>

Upvotes: 0

Tamil Selvan C
Tamil Selvan C

Reputation: 20199

Escape the quote or use single quote solved the problem.

Try

Escape the double quote within the quote

<?php
echo "<a href=\"http://www.quackit.com/common/link_builder.cfm\" onclick=\"basicPopup(this.href);return false\">Open a popup window</a>";

?>

or

Use single quote

<?php
    echo "<a href='http://www.quackit.com/common/link_builder.cfm\' onclick='basicPopup(this.href);return false'>Open a popup window</a>";
    ?>

Upvotes: 0

Zack Newsham
Zack Newsham

Reputation: 2992

Your problem is the quotes, however you don't need to echo it at all. If you need to echo variables inside the url, try this:

<a href="http://www.quackit.com/common/link_builder.cfm?<?php echo $variable;?>" onclick="basicPopup(this.href);return false">Open a popup window</a>

alternatively, you can escape the quotes inside the string using a backslash:

echo "<a href=\"http://www.quackit.com/common/link_builder.cfm\" onclick=\"basicPopup(this.href);return false\">Open a popup window</a>";

Upvotes: 1

Related Questions