TinyPortal

Development => Support => Topic started by: fermachado on November 17, 2008, 11:47:03 AM

Title: Include php file
Post by: fermachado on November 17, 2008, 11:47:03 AM
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
(http://www.enfoca2.com)

Thanks for your help and sorry my poor english.
Fernando
Title: Re: Include php file
Post by: G6Cad on November 17, 2008, 01:13:52 PM
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.
Title: Re: Include php file
Post by: fermachado on November 17, 2008, 01:49:32 PM
Hi,

I use the Photopost gallery.

Thanks,
Title: Re: Include php file
Post by: JPDeni on November 17, 2008, 01:51:34 PM
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.
Title: Re: Include php file
Post by: fermachado on November 17, 2008, 02:13:12 PM
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,
Title: Re: Include php file
Post by: IchBin on November 17, 2008, 02:22:46 PM
Did you try it?
Title: Re: Include php file
Post by: fermachado on November 17, 2008, 02:26:54 PM
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



Title: Re: Include php file
Post by: JPDeni on November 17, 2008, 02:30:06 PM
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.
Title: Re: Include php file
Post by: fermachado on November 17, 2008, 02:41:38 PM
Thaks,

SMF and Photopost share the same database.
Title: Re: Include php file
Post by: JPDeni on November 17, 2008, 04:12:42 PM
Ah. Well, then that solves the problem! Cool.  8)

You're welcome.
Title: Re: Include php file
Post by: fermachado on November 19, 2008, 01:24:38 PM
Hi,
Thanks,
Don't work !

I tried now put only this code
<?php
include('/home/fotogeni/public_html/testegaleria/inc_features2.php');
echo "$photopostfeature";
 
?>

But I have the 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

:(


Title: Re: Include php file
Post by: Zetan on November 19, 2008, 01:30:29 PM
Remove the opening and closing php tags:


<?php

?>

TP's php blocks/articles have these already included.
Title: Re: Include php file
Post by: Crip on November 19, 2008, 01:32:27 PM
ZTN 8)
Title: Re: Include php file
Post by: fermachado on November 19, 2008, 01:46:20 PM
I´m Stupid

Works, thanks :)
Title: Re: Include php file
Post by: Zetan on November 19, 2008, 01:50:00 PM
Quote from: fermachado on November 19, 2008, 01:46:20 PM
I´m Stupid

No you are not.. You don't know until you have learnt it, now you have, you won't do it again.. If you do.. then you're stupid  ;)

For future reference, try searching for the error: Parse error: syntax error, unexpected '<' , for example, you'll probably find it's been discussed before.
Title: Re: Include php file
Post by: fermachado on November 19, 2008, 02:39:00 PM
Thanks,

Mi english it's very poor and I don't understand at first time the help from JPDENI .

I'm not remember to search this error :( sorry

Thanks again for your  patience