code green 1,726
Recognized Expert Top Contributor
The following code is part of a script actioned by a web form
[PHP]if(isset($_POST['report']))#the form has been submitted
{
if($pls = $_POST['pls']) #hidden variable in pricesCostForm
{
$levels = array();
for($c=0;$c<$pl s;$c++)
{
if(isset($_POST['level'.$c]))
$levels[] = trim($_POST['level'.$c]);
} [/PHP] What do I add to the following command line - C:\apache\xampp\php\php-win.exe "C:\apache\xampp\htdocs\programs\Reports\Prices\pricesReportEntry.php"
so that $_POST['report'] is set
$_POST['pls'] equals 45
and $_POST['level'.42] = 'TEST'
so that the above code will create the array
This so the script can run via a scheduled task.
Thanks
6 5492 Atli 5,058
Recognized Expert Expert
You should be able to fetch command line arguments via the $argv array. Like, if you type into the cmd window: -
C:\apache\xampp\php\php-win.exe "C:\Path\To\File\myphpfile.php" first second third
-
And you had this in the myphpfile.php
It should output something like: -
Array
-
(
-
[0] => myphpfile.php
-
[1] => first
-
[2] => second
-
[3] => third
-
)
-
-
Don't have a Windows machine to test this on, but it does work on Linux.
Markus 6,050
Recognized Expert Expert
You know, I've never attempted PHP from the command line. Like OOP, it's always intimidated me.
Doesn't look to hard, actually. So I might give it a shot!
dlite922 1,584
Recognized Expert Top Contributor
So I might give it a shit!
I hope you don't.
A shot will be better.
Once you go OOP you never go back.
Command line is good for cron jobs. (scheduled tasks in Windows)
Maybe you need to clean up temp directories, clean up session table. FTP file somewhere, etc.
You could do it with PHP!
Markus 6,050
Recognized Expert Expert
I hope you don't.
A shot will be better.
Once you go OOP you never go back.
Command line is good for cron jobs. (scheduled tasks in Windows)
Maybe you need to clean up temp directories, clean up session table. FTP file somewhere, etc.
You could do it with PHP!
Oh dear.
What a bad typo!
I can't even edit it!
Jeeeez.
pbmods 5,821
Recognized Expert Expert
SuperMod to the rescue!
*sound of engine sputtering*
Oops. Forgot; my cape hasn't been reactivated yet. Well, it'll be a funny inside joke that we can't ever tell anyone else about ever.
Anyway. Here's everything you ever wanted to know and more about running PHP from the command line.
You can't simulate $_POST variables via CLI. But you could do something like this, if the code had to be runnable from both the command line and the web: -
define('IS_CLI', php_sapi_name() == 'cli');
-
-
if( IS_CLI )
-
{
-
$input =& $argv;
-
}
-
else
-
{
-
$input =& $_POST;
-
}
-
-
if( isset($input['report']) ) /** and so on */
-
code green 1,726
Recognized Expert Top Contributor
Thanks Atli. The argv array, what else.
The same as C hm.
I should have realised.
So I can tag the variables to the command line.
And then use pb_mods suggestion to edit my php
Thanks a lot guys
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Phil Powell |
last post by:
I need to find a PHP equivalent to a very familiar TCL command "subst"
(see http://www.hume.com/html84/mann/subst.html ).
This command will take a string and evaluate anything TCL inside of it
and return values.
for example, if this were my line:
set word {World}
|
by: Alan Silver |
last post by:
Hello,
I'm a bit surprised at the amount of boilerplate code required to do
standard data access in .NET and was looking for a way to improve
matters. In Classic ASP, I used to have a common function that was
included in all pages that took an SQL query and returned a disconnected
recordset. This meant that data access could be achieved in a single
line. I would like to do something similar in ASP.NET.
I know I could just duplicate...
|
by: Fred Weinhaus |
last post by:
I would like to make a redirect and pass the POST data to the redirected
page from the original page. What is the easiest way to do this? Can one
do this by setting the header data in some way. If so, how? Is there a
better way without using sessions. I am rather new to PHP. Thanks
Fred Weinhaus
|
by: tony |
last post by:
i'm trying to itterate through an array that contains the names of the
global arrays
eg:
$myarray = array("\$_GET", "\$_SERVER"); and so on
The problem Im having is calling a function with
myfunction($myarray);
|
by: admin |
last post by:
Hi,
I have a mysql box that has a private network ip. The old developer was
running our web server on this machine but the company since retired
the box and it is in a closet, still running, but sad and alone,
aliased as oldserver.mycompany.com.
Now I am finding out that I need to use some of the funcitonality in
the scripts that are on the old box.
| |
by: Atli |
last post by:
Introduction
At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect this data is essential to any developer.
This article is a basic tutorial on how to user HTML Forms, the most common method of data collection.
Assumptions
- Basic HTML knowledge.
- Basic PHP knowledge.
HTML Forms
A common and simple way of...
|
by: JRough |
last post by:
I tried to pass the $result from a mysql_query in a url like this line
Header("Location:clm_historyXL.php?_result=".$result);
but on the redirect location clm_history.php page I get an error on
this line:
$result = $_POST;
I need the $result on the clm_historyXL page to print a list to excel
because
of a header already being sent.
|
by: swetha123 |
last post by:
hello,
I don't know how to use cookies
please help me in this
I am using the dream weaver cs4
I designed the navigation bar to my page using dream weaver cs4
navigation bar contains Home, Retail Contact Us
|
by: anfetienne |
last post by:
hi i've got this code that writes data to a text file. When i test it with a standard array eg array(1,2,3) it works perfectly fine but when i try it with $_POST i get the error message
Warning: Invalid argument supplied for foreach() in /home/theau10/public_html/resources/captionSaveB.php on line 23
Warning: Invalid argument supplied for foreach() in /home/theau10/public_html/resources/captionSaveB.php on line 38
Warning: Invalid...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |