Wallpaper Script Forum » Announcements

Random PHP include

(11 posts)

Tags:

  1. and
    Member

    Hi guys,

    I need include random files in my homepage..

    Normally I use a code like this:

    $rnd = rand(1, 5);
    $filename = "file" . $rnd;
    include ("$filename")';

    or this:

    <?php $n=rand(1,5); include ("/file$n.php"); ?>

    It's the same...

    But obviously doesn't work with this script, return smarty errors.

    Any idea to solve this?

    Posted 1 year ago #
  2. You can write this in your php files or if you are writing this in ur tpl files then instead of " <? " you need to write {php} {/php} tag ..

    Posted 1 year ago #
  3. and
    Member

    Well Batu, let's go...

    I tried the two alternatives in the file index.tpl...

    First i use {include file="test.php"}... this file have the original random php code. No works...

    Then I changed "<?php?>" for {php}{/php} directly in index.tpl...

    I don't know if I did something wrong, but in both cases I receive a error like this:

    No such file or directory in ..../templates_c/%%45^45E^45E480CD%%index.tpl.php on line ...

    Was expected?

    Posted 1 year ago #
  4. I must say.. you are doing something wrong .. send me your tpl file.. I will look into it..

    Posted 1 year ago #
  5. and
    Member

    Ok Batu,

    Check attached file..

    Posted 1 year ago #
  6. and
    Member

    Sorry.. sent again.

    Attachments

    1. test.php.txt (0 KB, 3 downloads) 1 year old
    2. error2.txt (0.6 KB, 3 downloads) 1 year old
    3. error1.txt (0.6 KB, 5 downloads) 1 year old
    4. index.tpl1.txt (0 KB, 7 downloads) 1 year old
    Posted 1 year ago #
  7. and
    Member

    and again...

    Posted 1 year ago #
  8. and
    Member

    wtf? and again.. =D

    Attachments

    1. file.txt (0.1 KB, 10 downloads) 1 year old
    Posted 1 year ago #
  9. and
    Member

    last file it's index.tpl (option 2)

    Posted 1 year ago #
  10. I guess your last file shd work.. don't know why its not working..

    I guess You can write this in your index.inc.php file also..

    Posted 1 year ago #
  11. and
    Member

    You're right! I declared the variable in index.inc.php and then called in index.tpl.. guess what? it works!

    Tks again Batu, your help is very useful here!

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.