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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 777
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 82
  • Total: 82

Include php file

Started by fermachado, November 17, 2008, 11:47:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fermachado

Hi,

Link to my site: http://www.fotogenico.net/site
SMF version: SMF ver. 1.1.7
TP version:
TP ver. 1.0.5 beta
DzinerStudio : Mystic Jade
Mods installed: Advshoutbox

It's possible put a include php file or smae php code in one block in the front page?

I want to show featured photos from my gallery in the front page of the forum.Like in this site www.enfoca2.com


Thanks for your help and sorry my poor english.
Fernando

G6Cad

What gallery do you use ?

If you have coppermine then the answer is yes, but you need to have cpmfetch from commermine to get it to work.
If you have SMF gallery, jut use Thurnoks code from the block code and snippets board, it holds a lot of good features.

www.familjegodis.se uses thurnoks code on the frontpage php top block.

fermachado

Hi,

I use the Photopost gallery.

Thanks,

JPDeni

Yes, you can create a php block to go wherever you want it to be and, in that block, you can include another php file.

fermachado

Thnaks,

For example, if I paste this code in one php block.Works?

<?php  
$host   
'localhost'
$dbUser '*****';   
$dbPass '*****'
$db '.......'
mysql_connect("$host""$dbUser""$dbPass") or die(mysql_error());
mysql_select_db("$db") or die(mysql_error());

$result mysql_query("SELECT id,cat,bigimage FROM pp_photos order by rand() LIMIT 1" ) or die(mysql_error());   
while(
$row mysql_fetch_array$result )) {
print 
"<a href=\"/photos/showphoto.php/photo/" $row['id'] . "\"><img src=\"/testegaleria/data/" $row['cat'] . "/thumbs/" .  $row['bigimage'] . "\"></a>";
}
?>


Thanks,

IchBin


fermachado

Hi,

Yes, but get this error

Parse error: syntax error, unexpected '<' in /home/fotogeni/public_html/testeforum/Sources/Load.php(1735) : eval()'d code(52) : eval()'d code on line 1




JPDeni

Actually, no, that won't work. You can only have one database open at a time. If you open another database, you'll close the SMF database and nothing after that block that relies on the db will work.

You would do better to put your tables into the SMF database and then use the built-in structure for accessing the database. Once you move your tables, this would be the whole code that you would need to go into a block.


$result = db_query("SELECT id,cat,bigimage
FROM pp_photos
ORDER BY RAND()
LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_array($result);
print "<a href=\"/photos/showphoto.php/photo/" . $row['id'] . "\"><img src=\"/testegaleria/data/" . $row['cat'] . "/thumbs/" .  $row['bigimage'] . "\"></a>";


The reason you got the error you did is that you don't use the


<?php


at the beginning or


?>


at the end of php code in the blocks.

fermachado

Thaks,

SMF and Photopost share the same database.

JPDeni

Ah. Well, then that solves the problem! Cool.  8)

You're welcome.

This website is proudly hosted on Crocweb Cloud Website Hosting.