|
Posted by Jerry Stuckle on 03/10/07 13:56
Mike Russell wrote:
> <fishmonger1972@gmail.com> wrote in message
> news:1173481411.332250.5390@64g2000cwx.googlegroups.com...
>> I'm a librarian trying to put a finishing touch on an online materials
>> catalog. The line below seems to do nothing in my program.. And I
> ...
>> <?php if (defined($book_review_url)) echo "<a href=\"$book_review_url
>> \">Click here for reviews for $title on Amazon.com</a>"; ?>
>
> Others have mentioned use of isset(). Two other errors are that you should
> not escape the quotes in this situation, and use . to concatenate strings:
>
> echo "<a href=" . $book_review_url . ">Click here for reviews for $title on
> Amazon.com</a>"
> (watch for line breaks in this posted message)
>
Actually, the quotes need to be escaped. They are part of the HTML
code. $book_review_url will still be expanded. And he isn't doing
string concatenation. So no '.' is required.
The result should look similar to:
<a href="http://www.example.com/book_reviews">...
> There are some things you can do to make writing code like this easier. You
> can use an IDE with a built-in syntax checker to find errors as you type
> them in, instead of later - eclipse is my current favorite, and there are
> other excellent ones, or use php -l to do a quick syntax check. Also, copy
> code that others have written, rather than create it yourself from scratch.
No syntax errors. Just a problem with not using isset().
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|