You are here: Re: What's wrong with this simple line of code? « PHP Programming Language « IT news, forums, messages
Re: What's wrong with this simple line of code?

Posted by Mike Russell on 03/10/07 10:21

<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)

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.
--
Mike Russell
www.curvemeister.com/forum/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация