post command

Jim Ault jimaultwins at yahoo.com
Sun Aug 9 18:27:47 EDT 2009


Please remember that a 'variable' in Rev is not the same as a  
'variable' in a POST command sent to a PHP script.

The PHP script parses the *single string* that is passed into the  
following:
pairs of names and values...
the name of the variable PHP will use, the string value of the variable

Send this from Rev "flower=rose&plant=tree&shrub=Arbor%20Vitae"
( the %20 represents a valid space character to PHP)
----------
put "flower=rose&plant=tree&shrub=Arbor%20Vitae" into stringToSend
post "" to "http://thisdomain.com/landscaping/inventory.php"

PHP *parses* this incoming string to (case sensitive)
$flower  with a value of "rose"
$plant  with a value of "tree"
$shrub  with a value of "Arbor Vitae"

but not   $Shrub  or  $sHrub  or  $shruB

Trying to refer to $Shrub if it is not defined will produce and error  
and stop the PHP script execution.
PHP will render the error message as part of your visible web page.

------------------------
To pass an array, you need to (in Rev) convert the array to a single  
string with delimiters, pass this to PHP, and then run script lines in  
PHP to convert the string into an array (usually using a series of the  
'explode' function)

If a stack has a card for each {guitar, drum}
and a field listing {Flaminco, 400 and Stratocaster,3000}{snare,150   
base,350  tympani,2900}
An example string sent to PHP
build the string and then choose a name for the PHP script to use as  
the variable

*note, you must pass the legal variable name for PHP, and it needs to  
match the name that the PHP script will use to work with the variable.

"musicArr=guitar~Flaminco,400^Stratocaster,3000|drum~snare,150^base, 
350^tympani,2900"

//PHP allows multi dimensional arrays, so we need to build it from the  
string
$instruments = explode('|', $musicArr);
then you explode each instrument and add it to the $instruments array
then you explode each listed kind (Flaminco) and add it to the  
$instruments array
    and set the value at the same time  =>  with the price (eg $2900  
for the tympani)

The result is one PHP variable that is a multidimensional array such  
that
$price = $instruments['guitar']['Stratocaster']   // 3000
$price = $instruments['drum']['tympani']   // 2900

Fun and games and a little bit of stress.

Jim Ault
Las Vegas

On Aug 9, 2009, at 2:12 PM, Mark Schonewille wrote:

> Yves,
>
> First of all, you need to define a variable. Without variables, php  
> isn't even aware that you tried to send something. Second, you need  
> to urlEncode your data. For example:
>
> put "myVar=" & urlEncode(fld "myFld") into myString
> post myString to url "http://www.mondomaine.be/dossierscripts/ 
> test.php"
>
> If you have multiples variables, myString should be of the following  
> format:
>
> "myVar1=" & myData1 & "&myVar2=" & myData2
>
> where myDataX is urlEncoded.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> http://economy-x-talk.com
>
> Submit your software products to http://www.quickestpublisher.com  
> and get found!
>
> On 9 aug 2009, at 22:56, Yves COPPE wrote:
>>
>> re,
>>
>> text fld
>>
>> text tab text tab text
>> text tab text tab text
>> text tab text tab text
>> ....
>> about 10 lines
>>
>>
>> Greetings.
>>
>> Yves COPPE
>> yvescoppe at skynet.be
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

Jim Ault
jimaultwins at yahoo.com






More information about the use-livecode mailing list