Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
php in default page
I’m trying to add this php into my default page but I can’t seem to get it to work
<txp:php>
for ($i = 0; $i < count($items); $i++) {
<td><img src="=$items[$i]['LINK']" alt="=$items[$i]['LINK']" class="reflect rheight20" /></td>
}
</txp:php>
I keep getting the error
Parse error: syntax error, unexpected '<' in /home/6440/domains/build.danwoodward.com/html/textpattern/publish/taghandlers.php(2681) : eval()'d code on line 3
Im not a big php person so any help would be much appreciated, thanks.
Offline
#2 2007-01-14 22:10:29
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: php in default page
<td><img src="=$items[$i]['LINK']" alt="=$items[$i]['LINK']" class="reflect rheight20" /></td>
..is not valid PHP code.
See the FAQ, particularly the part about escaping to XHTML.
Alex
Offline
Re: php in default page
I am having troubles escaping the quotation marks in the code,
<td><img src="=$items[$i]['LINK']" alt="=$items[$i]['LINK']" class="reflect rheight20" /></td>
would you use echo 'foo';
or some other way of escaping
Offline
#4 2007-01-15 00:07:49
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Offline
#5 2007-01-15 06:10:15
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: php in default page
Here’s a bit of a correction, but you haven’t specified what $items
is. It’s obviously supposed to be an array, but you haven’t declared it.
<txp:php>
for ($i = 0; $i < count($items); $i++)
{
echo '<td><img src="'.$items[$i]['LINK'].'" alt="'.$items[$i]['LINK'].'" class="reflect rheight20" /></td>';
}
</txp:php>
Offline
Re: php in default page
thanks everyone for your input, its much appreciated,
Offline
Pages: 1