This script, a require_once() script for a larger script (serving as a PayPal IPN listener script), fails quickly; at line 27.
Run on my ISTps Unix machine the compiler throws the following error:

PHP Parse error: syntax error, unexpected ';' in /home/vg010web02/68/65/2926568/web/auxlib/web07/HTMLpages/paypl_ntllck_loopX3.php on line 27

Linne#
01 <?php
02-23 //Comments//
24
25 error_reporting(E_ALL ^ E_NOTICE);
26 $fp1 = fopen('SmpSbxLog.txt', "a");
27 fputs($fp1, "L.26 _loopX3a.php \n"); //<- ?? Why is ‘;’ unexpected?
28 $time_stamp = date('m/d/y h:i:s a');
...
Any suggestions on debugging will be appreciated.
Thnx
u-sit

    Can you show us a few lines above (and including) line #27 without modifying them (such as by prepending line numbers) and with the board's [noparse]

    ..

    [/noparse] bbcode tags?

      		error_reporting(E_ALL ^ E_NOTICE);
      		$fp1 = fopen('SmpSbxLog.txt', "a"); 
      		fputs($fp1, "L.27 _loopX3a.php \n");
      		$time_stamp = date('m/d/y h:i:s a');
      		mail("name@domain", "_loopX3a, L.29", $time_stamp .", "Body<p>");//TEST
      
      		//unmodified $req for postback to PayPal	
      	$req = 'cmd=notify-validate';
      	$req1 = $req;

      Sorry about that.
      u-sit

        You still missed one part of my request:

        bradgrafelman;10995860 wrote:

        with the board's [noparse]

        ..

        [/noparse] bbcode tags?

        (Note that bbcode tags, used by the vBulletin forum software, are in no relation to '<?PHP' and '?>' tags used by the PHP interpreter; the former will format your code nicely and color-code it for us, while the latter does not.)

        Now that I've added the tags for you, the problem becomes more obvious; notice how the color-coding goes all haywire? You've got some quoting issues on the '//TEST' line. Specifically, take a look at string after the $time_stamp variable - it's got three unescaped double quotes.

          Well the syntax highlighting on the forum shows where the problem is, you've got one too many quote marks on that mail() line. I presume you didn't need the one before Body, or you meant to escape it?

            Thanks bradgrafelman and Ashley Sheridan, the highlighting tool is a neat deivce.

            After removing the extra ';' in the main script it was rerun in unix and threw the same unexpected ';' error on the same line, which is ...
            fputs($fp1, "L.27 _loopX3a.php \n"); in the following snippet ...

            <?PHP 		//UnexpectedTest.php
                            error_reporting(E_ALL ^ E_NOTICE);
            		$fp1 = fopen('SmpSbxLog.txt', "a"); 
            		fputs($fp1, "L.27 _loopX3a.php \n");
            		$time_stamp = date('m/d/y h:i:s a');
                      ?>
            

            Curiously, running this snippet in unix throws ...
            'Could not open input file: UnexpedtedTest.php.' I don't get it.

            u-sit

              I don't see anything wrong with the snippet, is there any code above that at all, the error might be coming from somewhere further up in the code.

              Out of interest, are you using an editor with syntax highlighting? I'd definitely recommend one to avoid "unexpected blah blah" errors in your scripts.

                Here's the 1st 27 lines:

                <?php
                // paypl_ntllck_loopX3a.php
                // C:\Documents and Settings...\Ntllck\Pay_Pal\
                // testing_IPN_files\paypl_ntllck_loopX3a.php//
                // http://www.u-sit.net/auxlib/web07/HTMLpages/paypl_ntllck_loopX3a.php //
                // paypl_ntllck_loop3a.php //
                //Following Registration-Form data receipt by PayPal, //
                // PayPal POSTs back to this script. //
                // A. Receive 1st POSTback from PayPal //
                // B. Open a socket to PayPal //
                // C. Assign POST'ed vars from PayPal to local vars. //
                // D. Pack POST'ed data into $reg for POST-back to PayPal. //
                // E. fgets($fp, 1024) PayPal's immediate response (verification?) //
                // F. Check for transaction verification //
                // G. Paypal-verification = true; Internal check of validation //
                // H. Check payment_status is completed //
                // I. Check for duplicate txn_id //
                // J. Check for authentic receiver (ntelleck) email address //
                // K. Check that payment_amount/payment_currency are correct // //
                // L. Save data in paypal_payment_info_2 table //
                // M. Get client's purchased publications from PaypalOrders_2 //
                // N. Mail requested publications -- HI_txt.pdf -- //
                ////////////////////////////////////////////////////////////////////////

                	error_reporting(E_ALL ^ E_NOTICE);
                	$fp1 = fopen('SmpSbxLog.txt', "a"); 
                	fputs($fp1, "L.27 _loopX3a.php \n");

                ?>

                My editor is Notepad++

                u-sit

                  I don't see any problems with that code either. Are you sure that the code you've posted here is the same code as that that has the error? Are there any include files being used which have some kind of unterminated string that is cascading the issue down into this code?

                    If the error states that PHP couldn't open the file, then the problem obviously has nothing to do with your actual PHP code (how could it? PHP didn't even get a chance to look at it yet).

                    Sounds more like a problem with file paths or permissions. Is the latest code snippet you posted above the full contents of the file being executed? If so, how are you trying to execute PHP (e.g. if from the CLI, can you show us the full command you're using)?

                      He said it threw the same error, and then mentioned the error about not being able to open the file. I assumed that meant there were two errors now?

                        1) Started from scratch with the 'Could not open input file: UnexpedtedTest.php.' error. Re -cut & pasted the several lines in Notepad++, ftp'd to isp's unix and ran it. This time the error is no longer thrown.

                        2) The original error: 'PHP Parse error: syntax error, unexpected ';' in /home/vg010web02/68/65/2926568/web/auxlib/web07/HTMLpages/paypl_ntllck_loopX3.php on line 27'
                        is still thrown when the command, 'php paypl_ntllck_loopX3.php; is executed in unix. That file is the full IPN listener script whose 1st 27 lines are suspect.

                        Thnx for your continuing support.
                        u-sit

                          There are no parse errors in the code snippet you posted above in post #8. Thus either that code snippet doesn't contain what the actual file PHP is executing contains, or... well, that's all I can think of, really.

                            Thanks.
                            Since Firefox runs the code w/o complaint I'm closing this discussion and ignoring the compiler's extra ';' issue.
                            This is a great site.
                            I learn from each discussion.
                            u-sit

                              u-sit;10995881 wrote:

                              Since Firefox runs the code w/o complaint I'm closing this discussion and ignoring the compiler's extra ';' issue.

                              Er, that doesn't make any sense for two reasons:

                              1. Firefox does not "run" PHP code in any way, shape, or form for two reasons:

                                1. It can't see it. PHP files are executed on the server and only the output is visible to the end user's browser.

                                2. It can't understand it. Web browsers don't know what PHP code is, how to parse it, or how to execute it - that's a job left for the PHP interpreter.

                              2. PHP has no compiler - it's an interpreted language.

                                You have highlight root cause of my coding problems, namely I'm still a newbie.

                                1) Indicating that the code was run in Firefox is misleading. Firefox is given a url to the script in my ISP account. Where it runs and echos messages to my monitor and to files in my account.

                                2) Yes I know, but too easily forget, that php is interpreted, not compiled.

                                (At my age I probably should go back to DOS basic.)
                                Thanks again,
                                u-sit

                                  Write a Reply...