0

What is wrong in the following code?

<?php
    echo "<td class='column1'><a href='#' OnClick='windowpopup(". secure_base_url()`"product/item/". $itemid ."/); return false;'>$row->title</a></td>";?>
?>

Why doesn't a popup window come up?

1
  • Ah ha! Hidden HTML due to bad formatting! Commented Aug 30, 2010 at 4:23

3 Answers 3

5

After OP Clarification:

After viewing hidden HTML, I must say here's how your code should look like:

<?php
echo "<td class='column1'><a href='#' OnClick='windowpopup(\"". secure_base_url() ."product/item/". $itemid ."/\"); return false;'>{$row->title}</a></td>";
?>

The reason is same though. You need to escape correctly and use double quotes for variables to expand in PHP.

Old Answer

Use this:

 echo "{$row->title}";

Or

 echo $row->title;

The PHP String Documentation says that:

"The most important feature of double-quoted strings is the fact that variable names will be expanded."

So, to expand variable names, either use double quotes and as precaution enclose them in {} OR do not use quotes at all.

Sign up to request clarification or add additional context in comments.

Comments

2

String interpolation in PHP only works in double quotes.

Comments

0

Whats the value of $row->title. Also, using single quotes will print the variable name, rather than its value.

edit: Ahh so there is more. Shamittomar, seems to have fixed your problem =)

3 Comments

The second sentence is enough to answer the question :)
Yup =) Was trying to figure out why he 'can't popup window'.
the popup code was being concealed and I've fixed the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.