You are here: Re: [PHP] [suspicious - maybe spam] Using heredocs « PHP « IT news, forums, messages
Re: [PHP] [suspicious - maybe spam] Using heredocs

Posted by Jochem Maas on 01/21/05 16:29

Tim Burgan wrote:
> Hello,
>
>
> I've just tried using heredocs [1] for the first time, but I am
> receiving parse errors always on the very last line of my document.
>
> The error is caused by my heredocs. Am I using it correctly? When I
> replaced the heredoc with a string.. everything worked again.
>
> Here's my code with heredocs (and the lines before and after for context):
>
> /* Query the database */
> $db_sql = <<<SQL
>
> SELECT id, expiry, permissions
> FROM tblStudents
> UNION ALL
> SELECT id, expiry, permissions
> FROM tblStaff;
>
> SQL;


the token 'SQL' must be the first and only thing on that line (other
than the terminating semi-colon):

$db_sql = <<<SQL

SELECT id, expiry, permissions
FROM tblStudents
UNION ALL
SELECT id, expiry, permissions
FROM tblStaff;

SQL;

other that that your code was fine. :-)


> $rs = $db_connection->execute($db_sql);
>
>
> Here's my code without heredocs (and the lines before and after for
> context) - this works fine:
>
> /* Query the database */
> $db_sql = 'SELECT id, expiry, permissions FROM tblStudents UNION ALL
> SELECT id, expiry, permissions FROM tblStaff;';
> $rs = $db_connection->execute($db_sql);
>
>
> What am I doing wrong? Are there any requirements to using heredocs?
> I'm using PHP4, Apache, Win XP.
>
> [1]
> <http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc>
>
>
> Thanks
> Tim
>

 

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

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