This post doesn't exist anymore!

Custom PHP in Frog

Feed 8 posts, 3 voices

Avatar
79 posts

I cant get this to work in Frog, using in a page or a snippet, I get this error:

Parse error: syntax error, unexpected T_WHILE in /home/golevel/public_html/frog/app/frontend/classes/Page.php(192) : eval()'d code on line 12

Anyone know why? I am trying to read from database(a different table)

<?php
function getPortfolioItems($ours,$num=false,$tools=NULL,$services=NULL){
	$output = array();
	$sql = "SELECT * FROM `portfolio_items` WHERE `ours` = '".$ours."'";
	if($num > 0){
		$sql .= " LIMIT ".$num;
	}
	$result = mysql_query($sql) or die(mysql_error());
	echo mysql_num_rows($result) . $sql;
	$this->includeSnippet('portf_arrays')
	while($row = mysql_fetch_assoc($result)){
		// tools
		$aTools = explode(',',$row['tools']);
		$sTools = '';
		foreach($aTools as $value){
			if($sTools != ''){
				$sTools .= ', ';
			}
			$sTools .= $tools[$value];
		}
		$row['tools'] = $sTools;
		// services
		$aServices = explode(',',$row['services']);
		$sServices = '';
		foreach($aServices as $value){
			if($sServices != ''){
				$sServices .= ', ';
			}
			$sServices .= $services[$value];
		}
		$row['services'] = $sServices;
		// output
		$output[] = $row;
	}
	return $output;
}
?>
<?php

 getPortfolioItems(); 

?>
 
Avatar
79 posts

PS How did you get that bc. to work i can NEVER get the code views to work with textile I try it a 100 different ways :(

 
Avatar
79 posts

I guess it gets tricky when Id like to either include a file from the eval’d code(page/snippet), or try to do some mysql from the eval’d code, anyone know!

 
Avatar
1493 posts

PS How did you get that bc. to work . . .

Practice. ;)

Actually, the trick is to make sure you have a blank line before you use Textile’s “nn.” type paragraph markers. You can also have a look at the examples in the Textile Reference Manual, or edit that topic post and see what the markup looks like now.

Hope you get some PHP help, btw! ;)

 
Avatar
651 posts

You forgot to close the line above the while loop:

	$this->includeSnippet('portf_arrays')
	while($row = mysql_fetch_assoc($result)){

should be:

	$this->includeSnippet('portf_arrays');
	while($row = mysql_fetch_assoc($result)){

Notice the additional ‘;’

 
Avatar
79 posts

Hey that works, goodness i looked through it like 4 times and couldn’t find a missing ; haha! Man thanks frog can do anything :)