Sorry bpat1434 - I'm new to this, thought something went wrong with the first topic so reposted it.

bpat1434;10880476 wrote:

If your post doesn't show up immediately, don't go and try and repost the same topic. It will be reviewed by a mod first.

I'm not immediately seeing anything evident; however, what is the exact error you're getting? Is the php above "/www/address" or is there a real script name with that?

Give us a direct copy & paste of the entire file inside [noparse]

[/noparse] tags and a copy & paste of the full and exact error code. Then we'll go from there.

This is the contact form.
http://www.eamonsinnott.com/Gerkros2008/testing/Gerkros_Contact.html

Exact error is as follows

Parse error: parse error in /www/www.eamonsinnott.com/Gerkros2008/testing/contact.php on line 1

Complete php code is as follows.

<?php
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

// Build the email (replace the address in the $to section with your own)
$to = 'eoconnell@sinnott-design.com';
$subject = "Contact / Comments Form - Client";
$message = "$name said: $message";
$headers = "From: $email";

// Send the mail using PHPs mail() function
mail("$to, $subject, $message, $email");

// Redirect
header("Location: contact_thanks.html");
?>

Please let me know if you need anything else, appreciate you looking into this. Been tearing my hair out for the last 48 hours over it.

    for one your mail() function doesn't look right. Remove the double quotes in it. Put an exit; behind the header ('location') to make sure your script stops executing after that line. You're forgetting the $headers in your mail function as well.

    edit
    oh and furthermore, I don't think the problem is in this script. It seems like a weird error triggered by some weird syntax error somewhere, causing the error to say it's line 1, but really being something else. Are there any requires used anywhere in the script or is the PHP code we see here the only code that is executed?

      I'd have to agree with Desidnova. Try this for grins & giggles:

      <?php
      var_dump('Entering Script...');
      var_dump('Assigning Post vars to variables ... ');
      // Pick up the form data and assign it to variables
      $name = $_POST['name'];
      $email = $_POST['email'];
      $phone = $_POST['phone'];
      $message = $_POST['message'];
      var_dump('Setting up mail() variables ...');
      // Build the email (replace the address in the $to section with your own)
      $to = 'eoconnell@sinnott-design.com';
      $subject = "Contact / Comments Form - Client";
      $message = "$name said: $message";
      $headers = "From: $email"; 
      
      var_dump('Attempting to mail ...');
      // Send the mail using PHPs mail() function
      mail($to, $subject, $message, $headers);
      
      var_dump('Mail sent!');
      
      // Redirect
      //header("Location: contact_thanks.html");
      var_dump('Would be redirected now...');
      

      I commented out the header() redirect because with all the var_dumps() you'd not be able to use it. Run that and see if anything displays. If it does, what's the output? If not, what's the error message?

        Thanks guys. This is what I have.

        Fatal error: Call to undefined function: phpvar_dump() in /www/www.eamonsinnott.com/Gerkros2008/testing/processcontact.php on line 1

        Regards
        more.ie

          I take it you have <?phpvar_dump( on top of your script

          make that
          <?php
          var_dump(

            Check your line-endings. If you're running a mac server, sometimes it won't recognize \n line endings so all the code is on one line. If you're running a linux server, it won't recognize \r.

            Gotta love the differences in operating systems 🙁

              <?php
              var_dump is correctly displayed and all the endings appear to be correct.

              I have taken the liberty of taking a screen grab of the entire php file.

              Please look at this link
              http://www.eamonsinnott.com/Gerkros2008/testing/Picture-1.jpg

              The error remains the same.

              Thanks
              more.ie

              Desdinova;10880494 wrote:

              I take it you have <?phpvar_dump( on top of your script

              make that
              <?php
              var_dump(

                Create a new file: phpinfo.php

                within that file write:

                <?php
                phpinfo();
                ?>

                Let me know what comes out.

                Furthermore, do close your PHP at the end of the script with ?>

                  Hi Desdinova,

                  Created a new file called phpinfo.php you can see it online at
                  http://www.eamonsinnott.com/Gerkros2008/testing/phpinfo.php

                  Error of the following is displayed with the phpinfo.php
                  Fatal error: Call to undefined function: phpphpinfo() in /www/www.eamonsinnott.com/Gerkros2008/testing/phpinfo.php on line 1

                  The error remains the same with the php mail form.

                  Something to do with my computers?

                  Desdinova;10880499 wrote:

                  Create a new file: phpinfo.php

                  within that file write:

                  <?php
                  phpinfo();
                  ?>

                  Let me know what comes out.

                  Furthermore, do close your PHP at the end of the script with ?>

                    You don't need to close your php script. If you don't, it helps keep whitespace following the closing tag from printing which could cause issues in some scripts 😉 It's an option.

                    Like I said, if you're using a Mac, make sure the file is saved as a Unix file. So new-line characters are "\n" and not "\r".

                      it's likely the editor that you're using. It definitely is a new line error (\r\n). \r is used by linux-like systems, and \n by windows-like systems (or the other way around, google if you want to know). Your editor probably only uses one version of these (which I've seen more often on mac). Generally, every enter that you press, generates the \r\n characters, which are then rendered to new lines.

                      I recommend copy/pasting the code you have written to some other simple text editors, and saving it as a PHP file, just to see how it goes. I'll give you a good bet that one of them will have no parse errors, while others do.

                      You can read the code properly because your OS uses the line breaks you have used. The system you're running your scripts on is not.

                      Thinking of it, I think if you add a space (with the spacebar) after the <?php starting code (so it becomes <php(space here), the parse error will move, possibly to another funciton, but still line 1 (since there are no linebreaks! all your code is on 1 line on your server 🙂 )

                      Wow I feel so energetic now haha.

                      Makes any sense?

                        Windows: \r\n
                        Mac: \r
                        Linux: \n

                        If you just add a space after <?php then yes, the parse error will go away; however, those comments you have will comment out all your code because all your code is on one line 🙁 So it's best to just put your code on multiple lines.

                        I know TextMate has a good following and you can save the files in whatever line-endings you wish. Typically if you save it in Windows format (where all line endings are "\r\n") then you are most portable because \r is ignored by Linux, and the \n will be interpreted. Mac will use the \r and not the \n 😉 Finally, something good with windows!

                          Have used a programme called "TextEdit" on the Mac. A simple editor.

                          A new error this time. And I have looked over it. There is no spaces etc. and each line is clean.

                          Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /www/www.eamonsinnott.com/Gerkros2008/testing/processcontact.php on line 7

                          Parse error: parse error in /www/www.eamonsinnott.com/Gerkros2008/testing/processcontact.php on line 8

                          Which are the following 2 lines (line 7 & line 8)
                          $phone = $POST['phone'];
                          $message = $
                          POST['message'];

                          <?php
                          var_dump('Entering Script...');
                          var_dump('Assigning Post vars to variables ... ');
                          // Pick up the form data and assign it to variables
                          $name = $POST['name'];
                          $email = $
                          POST['email'];
                          $phone = $POST['phone'];
                          $message = $
                          POST['message'];
                          var_dump('Setting up mail() variables ...');
                          // Build the email (replace the address in the $to section with your own)
                          $to = 'eoconnell@sinnott-design.com';
                          $subject = "Contact / Comments Form - Client";
                          $message = "$name said: $message";
                          $headers = "From: $email";

                          var_dump('Attempting to mail ...');
                          // Send the mail using PHPs mail() function
                          mail($to, $subject, $message, $headers);

                          var_dump('Mail sent!');

                          // Redirect
                          // header("Location: contact_thanks.html");
                          var_dump('Would be redirected now...');

                            What's your phpinfo output? is magic_quotes_gpc enabled?

                              bpat1434;10880511 wrote:

                              What's your phpinfo output? is magic_quotes_gpc enabled?

                              Getting there.

                              In annoyance with the Mac, I have dumped it and working from a pc.

                              As a result of the php form. We have the follows.

                              string(18) "Entering Script..." string(37) "Assigning Post vars to variables ... " string(31) "Setting up mail() variables ..." string(22) "Attempting to mail ..." string(10) "Mail sent!" string(26) "Would be redirected now..."

                              As for the phpinfo.php
                              It is Version 4.3.2
                              http://www.eamonsinnott.com/Gerkros2008/testing/phpinfo.php

                                Guys thanks for all your help.

                                It was just the simple issue of working on a Mac that created the problems.

                                I find editing the files straight out of the hosting domain using a word pad worked.

                                Once again many thanks for making me feel welcome on php builder forum. I will definetely be back.

                                more.ie

                                  Note that you can still work on a Mac, you just have to be careful about line-endings. Good text editors (EditPlus for windows, TextMate for mac) will allow you to change line-endings (or File Encoding) as needed.

                                  Glad to hear you got it solved. If it's resolved, please mark the thread as such.

                                    Write a Reply...