Categories > TinyButStrong general (FR) >

Need help to run another Php script

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: pokemonjojo
Date: 2004-07-13
Time: 15:55

Need help to run another Php script

Hello i'm french, so my english is bad, lol, i'm sorry, but i need help.

First see the exemple page : http://www.tinybutstrong.com/apps/examples/tbs_us_examples.htm
and see the "Execute another script".

I have made nearly the same script, but i need to run php with variable.

I have write :

<?

include_once('tbs_class.php') ;

$test = 'examples.php?ref=jojo' ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('examples.htm') ;
$TBS->Show() ;

?>

but i have an error :

Warning: tbs_locator_replace(search.php?): failed to open stream: No such file or directory in /home/www/users/1/p/o/k/pokemonjojo/www/007-musik.com2/tbs_class.php on line 1127

Warning: tbs_locator_replace(): Failed opening 'search.php?' for inclusion (include_path='.') in /home/www/users/1/p/o/k/pokemonjojo/www/007-musik.com2/tbs_class.php on line 1127

and i have read all post for php inclution, but i have note found a solution.

If you have a solution.

Thank

By: Skrol29
Date: 2004-07-13
Time: 16:48

Re: Need help to run another Php script

Hi,

TBS uses the PHP function fopen() to read the file.
If the file path begins with 'protocole://' then PHP suposes that it is an URL and try to open it as an URL. Otherwise PHP try to open it as a local file.

So in your case, if the file is a PHP script that returns the content of the file, then it must be opened as an URL. So you have to provide and path like 'http://'.....'examples.php?ref=jojo'

You can build the path string using PHP internal variables like $_SERVER['SERVER_NAME'] and $_SERVER['SCRIPT_NAME']
By: pokemonjojo
Date: 2004-07-13
Time: 16:55

Re: Need help to run another Php script

ok, i know that, but if i write

<?

include_once('tbs_class.php') ;

$test = 'examples.php' ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('examples.htm') ;
$TBS->Show() ;

?>


i have no error.

I think the problème is if i write 'examples.php?ref=jojo'  << When there is variable.

Heu... do you speek french ?
By: Skrol29
Date: 2004-07-13
Time: 17:23

[fr] Re: Need help to run another Php script

Oui je parle français :)
C'est quoi le message d'erreur que tu as avec
  $test = 'examples.php'
?
By: Skrol29
Date: 2004-07-13
Time: 17:25

Re: Need help to run another Php script

Pardon, oublie mon message juste avant.

Oui c'est normale que tu n'as pas d'erreur car 'examples.php' est le nom d'un fichier local valide.
Mais 'examples.php?ref=jojo' n'est pas le nom d'un fichier local valide. C'est une URL relative.
By: pokemonjojo
Date: 2004-07-13
Time: 17:37

Re: Need help to run another Php script

ok mais tous marche bien quand je met $test = 'examples.php',

ca execute le fichier exemple.php sans problème, les echo 'Bla Bal Bla'; sont afficher correctement.

Le hic, c'est quand je veux passer une variable, genre $test = 'examples.php?ref=jojo'

il me met un message d'erreur, et ne m'affiche plus ce qu'il y a dans le fichier exemple.php (Normal car il ne le trouve pas)

Alors que dois-je faire ?

je suis bloqué!

Merci de tes réponses super rapide.
By: Skrol29
Date: 2004-07-13
Time: 17:51

Re: Need help to run another Php script

'examples.php' est bien le nom dun fichier PHP, mais 'examples.php?ref=jojo' n'est pas le nom d'un fichier PHP.

Ce que tu peux faire, c'est :

  $_GET['ref'] = 'jojo';
  $test = 'examples.php';
Attention tout de même que le script examples.php récupère la varibale à partir de $_GET['ref'] plutôt que $GLOBALS['ref'].
By: pokemonjojo
Date: 2004-07-13
Time: 18:47

Re: Need help to run another Php script

évidement !!! pourquoi dès fois, suis-je aussi bête !!!!

lol

En tout cas, merci beaucoup pour ton aide et ta rapidité, vraiment génial (Je vais faire de la pub pour http://www.tinybutstrong.com lol)

Et je te tiendrais au curant quand mon site sera finis.

Merci pour tout
By: eLiNK
Date: 2004-08-22
Time: 13:09

Re: Need help to run another Php script

Hi,

I hope there's nothing wrong if I expand the thread with my question.
It is somehow related.

Sorry to have to ask you a very basic question.

I'm trying to get the value of a variable ($test) from an included script (langsel.php).

The main part of my code (simplified for generalisation):

include_once('tbs_class.php');

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('MyTemplate.htm') ;

$langsel = 'langsel.php' ;
echo "test: ".$test."<br />\n";

$TBS->Show() ;


MyTemplate.htm containing [var.langsel;script=[val];getob].
The variable $test gets determined within langsel.php.

I tried making it global, returning it with 'return' command but no go.
By: Skrol29
Date: 2004-08-23
Time: 12:03

Re: Need help to run another Php script

Hi eLiNK,

[var] tags are usually merged during the Show() method.
Thus, in your script, your trying to echo the $test variable before the 'langsel.php' script is called.

You can use MergeSpecial() to merge [var] field before Show. You can also use the Render property to make Show() not exiting the application. Or you can use a [var.test] tag in you template after [var.lang] to see if it well definied.
By: eLiNK
Date: 2004-08-23
Time: 12:53

Re: Need help to run another Php script

Hi Skrol29,

thank you for your quick answer.
Actually I tried echoing $test (with
echo "test: ".$test."<br />\n";
) also after the Show() method. What perplexes me is that I don't get any message at all in this case, compared to when I echo $test before the Show() method.

I'll give a try to your suggestion with MergeSpecial(), as it seems to be relevant in my case. What I'm trying to do is getting the value of the language chosen (within langsel.php), which obviously determines which language files are used for the page.


By: Skrol29
Date: 2004-08-25
Time: 09:46

Re: Need help to run another Php script

The Show() method makes an exit() at the end. So nothing is executed after it. You can Use the Render property to not exit at the end. Its usge is explained in the manual.
By: botity
Date: 2004-08-26
Time: 08:38

Re: Need help to run another Php script

may be it is not linked with the topic but i just want to know if
it is possible to insert the result of a function instead of using an entire script .

in my table , on field indicates a percentage (here task_perc)
$sql="select task_id,task_name,task_perc from tbltask";
$TBS->MergeBlock("blocm",$Connection,$sql);
and i have defined a function take as argument this this field...( the function is inside a library that a i use for other files also)
then instead of showing the filed task_perc i want to show the result of the function , is it possible?
thanks in advance
By: Skrol29
Date: 2004-08-26
Time: 09:26

Re: Need help to run another Php script

You can do it using parameter onformat, or parameter onsection.
And maybe you can use the percentage format supported by TBS.