32 || strlen($_REQUEST['shout_comment']) > 255) $_REQUEST['op'] = 'get'; switch($_REQUEST['op']) { case 'add': //make sure there is no HTML to get in the way strip_tags($_REQUEST['shout_comment']); $sql = "INSERT INTO ".$database['prefix']."shoutbox (name, comment) VALUES ('".$_REQUEST['shout_name']."','". $_REQUEST['shout_comment']."')"; $recordSet = $db->Execute($sql); if ($recordSet === false) { $error->setError(ERR_DATABASE, $sql); return false; } //don't break, we want to always retreive the updated data case 'get': $sql = "SELECT * FROM ".$database['prefix']."shoutbox ORDER BY 'timestamp' DESC"; $recordSet = $db->Execute($sql); if ($recordSet === false) { $error->setError(ERR_DATABASE, $sql); return false; } //now that we have them, format the first 4, or show more depending on user action. $return_data = ""; //initialize variable for good measure. if(!isset($_REQUEST['sn']) || !is_numeric($_REQUEST['sn'])) $shout_num = 4; //4 is default else $shout_num = $_REQUEST['sn']; for($i=0; $i < $shout_num; $i++) { if($recordSet->EOF) return; $recordSet->fields['comment'] = wordwrap($recordSet->fields['comment'], 36, "\n
\n", 1); $return_data .= "

".$recordSet->fields['comment']."
by: ".$recordSet->fields['name']."

\n"; $recordSet->MoveNext(); } //build the appropriate link for displaying of more or less shouts if($shout_num != 4) $return_data .= "
Back to normal view"; else $return_data .= "
View last 10 shouts"; echo $return_data; break; } /* if($_REQUEST['shout_name'] != "" || $_REQUEST['shout_comment'] != "") echo "this is a test to see if the data was retrieved\n\n".$_REQUEST['shout_name']."\n".$_REQUEST['shout_comment']; */ ?>