TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 468
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 119
  • Total: 119

Having php show up in a block

Started by Ray, September 20, 2005, 06:07:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ray

Im trrying to add a php to a block and I have the block set to php but the block will not show anything - I have had this problem before just never asked-- here it the code


// Settings
$settings = ""; // SMF Settings file (Must set if not preview-mode or not in smf directory)
$preview = true; // Set FALSE if you include this
// End of settings

if($settings != "") require($settings); else require(dirname(__FILE__) . '/Settings.php');

$link = mysql_connect($db_server, $db_user, $db_passwd) or die(mysql_error($link));
mysql_select_db($db_name, $link) or die(mysql_error($link));


{

//   echo "
".print_r($game,true)."
";

   //echo "
".print_r($top,true)."
";

   foreach($top as $temp){
      echo "{$temp['name']} - {$temp['score']} at ". date("d m y", $temp['stime']) . " by {$temp['realName']}
";;
   }

   echo "<h2>High Game Scores</h2>";
   $top = highscore();
   //echo "
".print_r($top,true)."
";

   foreach($top as $temp){
      echo "{$temp['name']} - {$temp['score']} at ". date("d m y", $temp['stime']) . " by {$temp['realName']}
";;
   }


}

// Functions begin
// All returns array

// random_game( [category id] )
// highscore( [count=10], [game internal name] )



function random_game($cat_id = ""){
   global $link,$db_prefix,$boarddir,$boardurl;
   if($cat_id == "") $query = "SELECT * FROM {$db_prefix}games ORDER BY rand() LIMIT 0,1";
   else $query = "SELECT * FROM {$db_prefix}games WHERE category='{$cat_id}' ORDER BY rand() LIMIT 0,1 ";

   $game = mysql_fetch_array(mysql_query($query));
   $ext = array('gif','GIF','png','PNG','jpg','JPG',); // Extensions to look for
   $game['thumbnail'] = ""; // No thumbnail for default

   foreach($ext as $ex){
      if(file_exists($boarddir. "/Games/".$game['game'].".".$ex)){
         $game['thumbnail'] = $boardurl."/Games/".$game['game'].".".$ex;
      }
   }

   return $game;
}


function highscore($count = 10, $game = ""){
   global $link,$db_prefix,$boarddir,$boardurl;
   if($game == "")
   $query = "SELECT * FROM {$db_prefix}games,{$db_prefix}games_high,{$db_prefix}members WHERE {$db_prefix}games.game={$db_prefix}games_high.game AND {$db_prefix}games_high.member={$db_prefix}members.ID_MEMBER ORDER BY score DESC LIMIT 0,{$count}";
   else
   $query = "SELECT * FROM {$db_prefix}games,{$db_prefix}games_high,{$db_prefix}members WHERE {$db_prefix}games.game={$db_prefix}games_high.game AND {$db_prefix}games_high.member={$db_prefix}members.ID_MEMBER AND {$db_prefix}games.game='{$game}' ORDER BY score DESC LIMIT 0,{$count}";
   $res = mysql_query($query) or die(mysql_error());
   $top = array();
   while($x = mysql_fetch_array($res)){
      $top[] = $x;
   }
   return $top;
}

It works ok if you pull it up in a browser

bloc

It seems the "echo" which contain print_r in it, are commented out? this...

//   echo "

".print_r($game,true)."

";


Should maybe be:

echo "  ".print_r($game,true)." ";

Ray

Tried that didnt work.

But works ok like this??


borgBOB

Get this to work Ray? I also installed the arcade mod and may want to add this.
Thanks

gerrymo

All you echos are commented out. Try changing them all, not just the first one.

This website is proudly hosted on Crocweb Cloud Website Hosting.