Forum for discussing general topics related to Couch.
10 posts Page 1 of 1
Hey guys, trying to run php within embedable templates, from our discussion, i used <cms:php> which seems to work fine, but I ran into this error:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/joicohen/public_html/couch/tags.php(1728) : eval()'d code on line 71

Parse error: syntax error, unexpected T_STRING in /home/joicohen/public_html/couch/tags.php(1728) : eval()'d code on line 71

these 3 lines seem to be causing it:

$v = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $v);
$v = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $v);
$v = preg_replace("#(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $v);

it worked fine when wrapped in php tags before.

thanks for the help :)
Hi Mr. Haroun,

It seems you have stumbled upon a real bug - a really obscure one where Couch's parser was stripping off any backslash character that preceded a quote character (i.e \" would become ") in any non-Couch text.
Normally this goes unnoticeable, however for the regex within your PHP code it was an error.

I have rectified the bug and am attaching the two modified files. Please overwrite the original two files in your installation with the ones attached.

These changes will go into the next minor release of Couch.

Please do confirm back if this solves the problem you were encountering.

Thanks

Attachments

I will give this a shot.
I am running into another issue. not sure if they are related.

$images = $f->images_get('AlbumID=<cms:show albumid />', 'AlbumKey=<cms:show albumkey />', 'Heavy=1');
this line causes this error:
Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/joicohen/public_html/couch/tags.php(1728) : eval()'d code on line 33

when used within <cms:php>

it is used to fetch images from a smugmug gallery, the albumid and key being 2 variables needed to fetch the correct page.
Hi,

I had a look at your code and am emailing back the rectified version (it is fetching the images on my system).

The problem was that you were using the code
Code: Select all
$aid = <cms:show albumid />;

without checking whether the page being displayed is in the page_view or the list_view (please see http://www.couchcms.com/docs/concepts/views.html).

In list_view, albumid (or value of any editable regions associated with a particular page) will come up blank thus rendering the above statement as -
Code: Select all
$aid = ;

which is invalid syntax and ergo the PHP parse error.

The solution is to put in a check before using the php tag -
Code: Select all
<cms:if k_is_page>
   <cms:php>
         $aid = <cms:show albumid />;
         $akey = <cms:show albumkey />;

         try {

         $images = $f->images_get('AlbumID='.$aid, 'AlbumKey='.$akey, 'Heavy=1');
         $images = ( $f->APIVer == "1.2.2" ) ? $images['Images'] : $images;

         // Display the thumbnails and link to the medium image for each image
         foreach ( $images as $image ) {
            echo "<a href='". $image['LargeURL'] . "' rel='prettyPhoto[pp_gal]'><img src=".$image['TinyURL']." border=\"0\" /></a>";
         }
         }
         catch ( Exception $e ) {
            echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
         }
         $f->clearCache();
   </cms:php>
</cms:if>


Please let me know if this helps.
Ran into a similar error, tried the patch but both files require couch.lic and I don't gat that.

Will try and clean up the code for now since I now know its most likely a "\'" somwhere...
---
You live many times, but only ever remember your lives.length - 1
---
Image
Hey cholasimmons,
That patch is nearly three years old :)
The bug has long been fixed, my friend.

What exactly is the problem you are running into anyway?
Please post it here and we'll try to find the reason.

Thanks.
Lol I don't know why I didn't even check.
I'm getting a parse error syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in tags.php(841) eval()'d code on line 1, warning cannot modify header info - headers already sent by (output started at tags.php(841) eval()'d code 1 in cms.php on line 376

This only happens on one page out of all 7, only in page view. The same page in list view works ok
---
You live many times, but only ever remember your lives.length - 1
---
Image
Please post in the exact code (PHP) you are using as the problem obviously lies in its syntax somewhere.
Along with all the embedded files too? Whatever is wrong is affecting my styling aswell. The dropdown lists have shrunk in height and a few span areas have shifted upwards a few pixels.
Let me try a little process of elimination before I post the code.
---
You live many times, but only ever remember your lives.length - 1
---
Image
Failed! Lol

Please take a look at the error here by selecting the property...

I will PM the files shortly.
---
You live many times, but only ever remember your lives.length - 1
---
Image
10 posts Page 1 of 1