There is this line in a code I have to modify in order to be able to use:

%response = $lperl->curl_process($myorder);

And I can't find anywhere what does %response stand for nor what the % operator is used for in this line...

It is clear that I'm not an OOP PHP programmer so I can't even begin to understand this line...

Anyways it gives me a syntax error and I can't use it like this...

I searched the PHP manual for % operator all I get is nothing since it is is somekind of wildcard sign and same situation on these forums...

All I know is that % is used as modulo operator but that's clearly not the case here...

Can anyone enlighted me?

    Originally posted by bodzan
    There is this line in a code I have to modify in order to be able to use:

    %response = $lperl->curl_process($myorder);
    

    [...]

    Anyways it gives me a syntax error and I can't use it like this...[/B]

    just imagine you want to type a $ which is [Shift] and [4] and by accident don't press [4] but [5]... what would you get?

      ...since there are two lines with the same thing...

      And I can swear that I saw that somewhere else, too, but I can't remember where...

      Anyways thank for trying to help mrhappiness...

        if you replace those two % with $ what happens?

        do you still receive errors: post them
        do you don't receive any more errors: tell us, so that we can stop think about it

          ...but I get the

          Fatal error: Call to a member function on a non-object...
          

          ...

          So the % doesn't belong there, but why would someone place it there in the first place and do it twice?

          Is this some OOP thingy?

            Only recently got into OOP stuff with PHP myself, but I've never come across % being used and can't imagine it could ever be used in this way. %varname is however used in Perl to signify a hash (associative array) which might explain the $lperl parameter name.

            From what you describe of the error it sounds like they've done a bit of a half baked job or something has been deleted.

            There should be a line similar to...

            $lperl = new myclass();

            ....above the line causing the error, although myclass() should be the name of the class in question. If there isn't then we might need to do a little more detective work.

            I don't suppose the source code for this script is available to be viewed anywhere? Just might make the job of solving the fault a lot quicker if it could be seen in a .txt file for example.

            Trev

              <?
              echo"<html><body><br>";
              include"lphp.php";
              $mylphp=new lphp;
              # constants
              
              # form data
              $myorder["cardnumber"] = $_POST["cardnumber"];
              $myorder["cardexpmonth"] = $_POST["cardexpmonth"];
              $myorder["cardexpyear"] = $_POST["cardexpyear"];
              $myorder["chargetotal"] = $_POST["chargetotal"];
              $myorder["ordertype"] = $_POST["ordertype"];
              if ($_POST["debugging"]){
              	$myorder["debugging"]="true";
              }
              # Send transaction. Use one of two possible methods
              # %response = $lperl->process($myorder); # use shared library model
              %response = $lperl->curl_process($myorder); // or use curl methods
              if ($result["r_approved"] != "APPROVED") // transaction failed, print the reason
              {
              print "Status: $result[r_approved]<br>\n";
              print "Error: $result[r_error]<br><br>\n";
              }
              else // success
              {
              print "Status: $result[r_approved]<br>\n";
              print "Transaction Code: $result[r_code]<br><br>\n";
              }
              # if verbose output has been checked,
              # print complete server response to a table
              if ($_POST["verbose"])
              {
              echo "<table border=1>";
              while (list($key, $value) = each($result))
              {
              # print the returned hash
              echo "<tr>";
              echo "<td>" . htmlspecialchars($key) . "</td>";
              echo "<td><b>" . htmlspecialchars($value) . "</b></td>";
              echo "</tr>";
              }
              echo "</TABLE><br>\n";
              }
              ?>
              </body></html>
              

              I left out connection details, but this is the code in full...

              trevHCS thanx for trying to help, man...

                Try changing the line:

                %response = $lperl->curl_process($myorder);

                ...to...

                $response = $mylphp->curl_process($myorder);

                ...and see if that works.

                Trev

                  Originally posted by bodzan
                  ...but I get the

                  Fatal error: Call to a member function on a non-object...
                  

                  ...

                  So the % doesn't belong there, but why would someone place it there in the first place and do it twice?

                  Is this some OOP thingy? [/B]

                    And same error message?

                    This is very bizare as the class must be alright otherwise that would throw an error and the function must exist within the class.

                    Which version of PHP are you using? When searching for this I did find mention of a bug in PHP5 although there weren't specifics as to exactly which version caused it.

                    Maybe try just below the $mylphp=new lphp; line:

                    var dump($mylphp);

                    I'm not 100% sure what it'll output, but I'm hoping something about a standard object.

                    If this doesn't work and no one else has any ideas, the next step is to write a small class and try to run it on your machine. At least if that throws an error we'll know it's not your script.

                    Trev

                      ...since I can most probably go past that using just other things since there is a number of ways to do this (using cURL...)...

                      I just wanted to know what this stands for in case I can't go around it...

                      But to answer your questions:
                      php 4.3.11 on Wun 2000 with Apache 2.0.49 as a server...

                      I have to say something first:
                      this lphp.php is a page that I'm supposed to include however I haven't got a faintest idea what is it?

                      In manual for this code it says that this code calls out to the functions in the lpPHP.pm module. Whatever that might be...

                      I gues that has something to do with it...

                        well, i copied that code and ran it through the php syntax checker (php -l file.php) and this is what it returned:

                        Parse error: parse error, unexpected '%' in test.php on line 18
                        Errors parsing test.php
                        
                        shell returned 255
                        

                        so as you can see its invalid and causes the interpreter to bail out. who knows what the person was thinking.

                        edit, and also changing the % to $ results in "No syntax errors detected in test.php"

                          I just wanted to know what this stands for in case I can't go around it...

                          Need to go do a few more tests on this one as I can't remember whether it means it can't find curl_process() within the lphp class or if it means the $mylphp isn't a copy of the lphp class.

                          But to answer your questions:
                          php 4.3.11 on Wun 2000 with Apache 2.0.49 as a server...

                          Hmm, so not being affected by the PHP5 bug then. Guess the error must be real then.

                          this lphp.php is a page that I'm supposed to include however I haven't got a faintest idea what is it?

                          By the sounds of it, that script contains the class (group of functions) including the curl_process() function referenced later on. Can't say for sure without seeing it however.

                          In manual for this code it says that this code calls out to the functions in the lpPHP.pm module. Whatever that might be...

                          Not sure, but it sounds more and more like this script was ported from Perl and not very well.

                          Trev

                            ...but since the thing is like it is I switched to the pure cURL method of doing the same thing and so far I had no problems with it so thats the way I'm going to do it...

                            However the question still stands: what does %something stand for? Is it an OOP thing or perl quirck?

                            If nothing else I would like to know that for future encounters if there are going to be...

                              It's a bug - someone who was used to programming in Perl and didn't test their code when it switched to PHP. Perl uses %, @ and $ for different variable types whereas PHP always uses $ (except for constants, but who uses them).

                              If you get to stupid ones like Javascript and VB (I think) they don't even seem to use a $ which is even more confusing.

                              Trev

                                ...thanx a lot trevHCS for all the hard work in helping me figure this...

                                I'll mark this thread resolved, but if anyone else has different idea please share with us...

                                  Write a Reply...