Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-14 21:22:29

danwoodward
Member
From: Brooklyn NY
Registered: 2006-08-06
Posts: 51
Website

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

#3 2007-01-15 00:02:33

danwoodward
Member
From: Brooklyn NY
Registered: 2006-08-06
Posts: 51
Website

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

Re: php in default page

Please read the PHP manual. This is not a Textpattern issue.


Alex

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

#6 2007-01-15 06:18:46

danwoodward
Member
From: Brooklyn NY
Registered: 2006-08-06
Posts: 51
Website

Re: php in default page

thanks everyone for your input, its much appreciated,

Offline

Board footer

Powered by FluxBB