Jump to content

Recommended Posts

I'm a newbie here, so please try to bear with me. I have a number of files on my webserver that I want to run every hour, normally I would a cron job, but I need to run some of the files with a variable: e.g 'a.php?num=20' some of these scripts are basically copies of themselves with different user data if that has any bearing.

 

But I tried to use the include function (later figured out it didn't support variables), Any thoughts or idea? I would like to run 1 sleep is for 10 seconds then run the next and so on and so forth. Any help is greatly appreciated thanks! (webserver is php5, apache)

 

Thanks!

I had this earlier, and basically it comes back:

#!/ramdisk/bin/php5 Read the PHP file

which I assume is working correctly :)

 

But I actually want it to execute the php script with the variable as if I were just going to it through the web.

 

For instance I run these manually by typing in the HTTP address: http://example.com/example.php?num=20

 

and then the same for example1.php example2.php, etc

I have a number of files on my webserver that I want to run every hour, normally I would a cron job, but I need to run some of the files with a variable: e.g 'a.php?num=20' some of these scripts are basically copies of themselves with different user data if that has any bearing.

You can pass them as arguments in the PHP file. Here's a good example:

http://web.jaypedia.com/web/cron/how-to-pass-php-cron-job-parameters-arguments-or-variables.htm

 

session's or $_GET['']

 

<?php
// url websit/name.php?cmd=redarrow

if(isset($_GET['cmd'])){

echo $_GET['cmd'];
}
?>

.

more safe.

<?php
// url websit/name.php?cmd=redarrow

if(isset($_GET['cmd'])&& $_GET['cmd']!=''){

echo $_GET['cmd'];
}
?>

King Philip --- Thanks if I can't seem to get this I will give that a solid go.

 

Red arrow this is what I went ahead and did, and no errors popped out, but the script didn't seem to run (sorry i'm very new at this)

 

<?php
// url http://example.com/abc.php?num=20

if(isset($_GET['num'])&& $_GET['num']!=''){

echo $_GET['num'];
}
?>

 

That was my code (url changed)

 

tested.

 

test it your self mate.

<?php

echo "<a href='{$_SEVER['PHP_SELF']}?num=20'>Link</a>";

if(isset($_GET['num'])&& $_GET['num']!=''){

echo $_GET['num'];

exit;

}else{

echo "sorry does not match!";
}
?>

 

look at this for fun.

 

<?php session_start();

$array=array(1,2,3,4,5);

$arra=implode(' ',$array);

$_SESSION['num']=$array;

echo "<a href='{$_SEVER['PHP_SELF']}?num={$_SESSION['num']}>Link</a>";

if(isset($_GET['num'])&& $_GET['num']!=''){

$result=implode(' ',$_SESSION['num']);

echo $result;

exit;

}else{

echo "sorry does not match!";
}
?>

 

my second example was crap ignore it ok,

 

look at this one quite interesting i say.

<?php session_start();

$array=array(1,2,3,4,5);

$implode=implode(' ',$array);

$_SESSION['cmd']=$implode;


echo "<a href='{$_SEVER['PHP_SELF']}?num=".$_SESSION["cmd"]."'>Link</a>";

if(isset($_GET['num'])&& $_GET['num']!=''){

$result=explode(' ',$_GET['num']);

$_SESSION['res']=implode(' ',$result);

echo $_SESSION['res'];

exit;

}else{

echo "sorry does not match!";
}

?>

 

hope all these ways help.

 

even better cheek this out.

 

<?php session_start();

$array=array("redarrow","php","myslq","html","css");

$implode=implode(' ',$array);

$_SESSION['cmd']=$implode;


echo "<a href='{$_SEVER['PHP_SELF']}?num=".base64_encode($_SESSION["cmd"])."'>Link</a>";

if(isset($_GET['num'])&& base64_decode($_GET['num'])!=''){

$result=explode(' ',base64_decode($_GET['num']));

$_SESSION['res']=$result;
}

if(isset($_SESSION['res'])){

     echo"<br>";
	echo $_SESSION['res'][0];
	echo"<br>";
	echo $_SESSION['res'][1];
	echo"<br>";
	echo $_SESSION['res'][2];
	echo"<br>";
	echo $_SESSION['res'][3];
	echo"<br>";
        echo $_SESSION['res'][4];

         session_destroy();
	 }
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.