PHP Email Error


#1

HI … I’m new at PHP, and did some research to find this script. However, when I try to run it, I get the following error:
syntax error, unexpected T_STRING in /home/.patch/myusername/mydomain/my.php on line 2.

Here’s the script:

<?php $to = "tlsarna@wyan.org"; $subject = "Reminder Message - SC3Arts Production Arts Team Service This Weekend!"; $body = "REMINDER: You are scheduled to serve on the Production Arts team this weekend! If you are unavailable to serve, please contact a replacement or send an email to cfoust@southpointccc.org.\nTo check this week's schedule, login here: http://www.sc3arts.com/pages/pa/thiswk.shtml. If you are unable to login, please contact Toni Lynn Sarna at webmistress@sc3arts.com with your desired password, so that she can set you up with access.\n\nThanks for your service, and God bless!"; mail($to, $subject, $body) ?>

#2

Try escaping the @ characters the email addresses:


#3

I tried that, as well as trying adding a semicolon to the end of the mail() line - neither worked. Same error.


#4

This is a wild guess, but how do you edit and upload your scripts? With text files and FTP it usually works better if you do an ASCII upload so that end of line characters get translated properly. A lot of servers are UNIX or Linux and requires a line feed character for end of line. Your server may be seeing the script as one long line.


#5

I built this in Wordpad, and just saved it as a PHP file - I also thought this might be the problem. Can you tell me what steps I would take to make the server recognize it?


#6

I think it was a problem with the PHP 5 install. My blog and activecollab installs weren’t working for a few minutes but they are now. Try 'em again ; )


#7

Wordpad is capapable of saving files as plain DOS text, make sure though by using Save As. That would give you a file with each line terminated by a carriage return/new line character. Windows might give you some problems using a .php extension, if so just use a .txt extension then change the file name after you upload it.

If your web site is on a Windows server and you have a true plain text file, either an ASCII or binary upload should work. Chances are it will be some flavor of UNIX or Linux though. To convert the DOS text file to a UNIX text file (lines terminated by a line feed character only) you would need to set your FTP program to do an ASCII transfer rather than binary. How you do that depends on what file transfer software you use. That will convert every carriage return/line feed end of line character to line feed only as the file uploads.

Some information you might want to have on hand (and will help if you post questions) is the operating system of your PC and the server, how you do file transfers, and what software you use.

Also, if you have shell access, which means you can edit the php file on the server, it will not only be automatically the correct format but it can also simplify trouble shooting. You can save the changes, then run it again to see what happens skipping the upload step.

If you accidentally upload a DOS text file to a UNIX or Linux server and open it in a text editor such as vi or emacs at the command line, you will see a ^M at the end of each line.


#8

[quote]Also, if you have shell access, which means you can edit the php file on the server, it will not only be automatically the correct format but it can also simplify trouble shooting. You can save the changes, then run it again to see what happens skipping the upload step.

If you accidentally upload a DOS text file to a UNIX or Linux server and open it in a text editor such as vi or emacs at the command line, you will see a ^M at the end of each line.[/quote]
All this post is good advice; I only have a couple of things to add:

  1. On DH (and most *nix systems) if you have shell access you can convert a file you made in Windoze to linux format after you have uploaded it using the “dos2unix” command. - For instructions, tyupe "man dos2unix " (no quotes, means to hit the “Enter” key).

  2. If you regularly work on a Windoze system to create text files for use on *nix systems, you can avoid all this by simply selecting and using a text editor that can save files with *nix line endings - there are many such editors avilable on the web that are “free” (“free” as in freedom as well as “free” as in free beer).

–rlparker


#9

Thanks to everyone for their help!! I have fixed the problem by rewriting in Frontpage, removing the HTML coding … it worked!! I do have Shell access, and am enjoying learning Linux - but not real comfortable in it yet.

Thanks again!