1
RichMcNinch
question about using PHP code in custom blocks
  • 2004/6/22 5:15

  • RichMcNinch

  • Just popping in

  • Posts: 2

  • Since: 2004/6/21


Can't seem to find any docs on this, so here goes:

The ubercool block system includes a feature to let you add custom blocks, and it has a PHP toggle for using custom PHP code.

I have a piece of standalone code that works anywhere on my site. However when I add these lines to the block, no results appear on the page. I see the header for my custom block, but no content. Am I missing some magic lube?

///////////////////
/* Grab most recent movie */
$DBhost = "localhost";
$DBuser = "**********";
$DBpass = "**********";

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database");

$DBName = "videodb";
$table = "videodata";

@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $table ORDER BY created DESC LIMIT 1";
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);

$i = 0;
while ($number > $i) {
$thetitle = mysql_result($result,$i,"title");
$thedir = mysql_result($result,$i,"director");
$theid = mysql_result($result,$i,"id");
$theimg = mysql_result($result,$i,"imgurl");

preg_match("/\.(jpe?g|gif|png)$/i", $theimg, $matches);
$newmd5 = md5($theimg);
$ext = $matches[0];
$thumb = "http://www.richmcninch.com/videodb/cache/img/$newmd5$ext";

print "


Title: $thetitle
Director:
$thedir

";
$i++;
}
?>
/////////////////

Thanks for any help you can offer.

2
Bassman
Re: question about using PHP code in custom blocks
  • 2004/6/22 5:49

  • Bassman

  • Friend of XOOPS

  • Posts: 1272

  • Since: 2003/5/23


my understanding is, you leave off the , and all the///////'s before and after them too I guess. Then it should work.

3
RichMcNinch
Re: question about using PHP code in custom blocks
  • 2004/6/22 7:03

  • RichMcNinch

  • Just popping in

  • Posts: 2

  • Since: 2004/6/21


OMG YOU ROCK

Thanks man...So simple, I was overdoing it. Works great and a whole new level of functionality has just opened up to me. Thank you.

4
Mithrandir
Re: question about using PHP code in custom blocks

Are you using another database than the XOOPS one for this block?

If not, you can just skip the entire connectivity and just declare $xoopsDB global.

5
flyingwolf
Re: question about using PHP code in custom blocks
  • 2004/6/22 19:23

  • flyingwolf

  • Just popping in

  • Posts: 1

  • Since: 2004/6/22


Ok after reading this post i got my includes to work. However I have a problem when I use this script.

require("config.php"); 
 
 
$db->open("SELECT songlist.*, historylist.listeners as listeners, historylist.requestID as requestID, historylist.date_played as starttime FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S')   ORDER BY historylist.date_played DESC LIMIT 6");
 
$history $db->rows();
 
reset($history);


It bassicly breaks the page and stops it from loading.

If you know what SAM2 Broadcaster is then that is what I am trying to integrate into xoops.

Oh and I noticed XOOPS is rather slow even on my extremely fast servers.

Login

Who's Online

330 user(s) are online (235 user(s) are browsing Support Forums)


Members: 0


Guests: 330


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits