470,572 Members | 2,561 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,572 developers. It's quick & easy.

Bizarre problem when trying to write to a csv

I'm obtaining a weird message when I try to add the capability to write to a csv file into the formmail script that I'm using. Everything is fine initially and the email comes through to me perfectly from the simple HTML form I've designed. However, when I add the path to the CSV directory into the appropriate section in the php script being called, I get the following when I run the script:

Parse error: parse error, unexpected ';' in /home/myaccount/public_html/suggest/Feedback.php on line 5439

The $CSVDIR section looks like this:

Expand|Select|Wrap|Line Numbers
  1. $CSVDIR = "/home/myaccount/public_html/csvdir";                        // directory for csv files; empty string to
  2.                                     // disallow csv files
  3. $CSVSEP = ",";        // comma separator between fields (columns)
  4. $CSVINTSEP = ";";    // semicolon is the separator for fields (columns)
  5.                     // with multiple values (checkboxes, etc.)
  6. $CSVQUOTE = '"';    // all fields in the CSV are quoted with this character;
  7.                     // default is double quote.  You can change it to
  8.                     // single quote or leave it empty for no quotes.
  9. //$CSVQUOTE = "'";    // use this if you want single quotes
  10. $CSVOPEN = "";        // set to "b" to force line terminations to be
  11.                     // kept as $CSVLINE setting below, regardless of
  12.                     // operating system.  Keep as empty string and
  13.                     // leave $CSVLINE unchanged, to get text file
  14.                     // terminations for your server's operating system.
  15.                     // (Line feed on UNIX, carriage-return line feed on Windows).
  16. $CSVLINE = "\n";    // line termination for CSV files.  The default is
  17.                     // a single line feed, which may be modified for your
  18.                     // server's operating system.  If you want to change
  19.                     // this value, you *must* set $CSVOPEN = "b".

The section giving the error looks like this with the "if" part being Line 5439:

Expand|Select|Wrap|Line Numbers
  1. {
  2.     global    $TARGET_URLS;
  4.     foreach ($TARGET_URLS as $s_prefix)
  5.         if (!empty($s_prefix) &&
  6.                 strtolower(substr($s_url,0,strlen($s_prefix))) ==
  7.                 strtolower($s_prefix))
  8.             return (true);
  9.     return (false);
  10. }

I don't know what's wrong with this. More bizarrely, when I remove this CSV modification and revert to the original script, this error stays! I'm not a programmer so I'm a bit stuck here. I'm just trying to use the script as an "out-of-the-box" solution.

Any help greatly appreciated.

Aug 27 '07 #1
3 1397
802 Expert 512MB
Replace && with && in the below code.
[PHP]if (!empty($s_prefix) &&
strtolower(substr($s_url,0,strlen($s_prefix))) ==
It will become
[PHP]if (!empty($s_prefix) &&
strtolower(substr($s_url,0,strlen($s_prefix))) ==
Aug 27 '07 #2
Thank you.

I think I see what's happened here. I opened the PHP file in a web editing program and it appears to have put all these wacky characters in as replacements for &, ", <, >. It doesn't look like it was anything to do with the script at all. Looks like some painstaking editing with Notepad is looming! Thanks again for your help.

Aug 27 '07 #3
5,821 Expert 4TB
Heya, Dave.

I award 15 points for creative use of [b] tags. However, I have to deduct 15 points for not using [code] tags.

Better luck next time.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 28 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Alan Little | last post: by
11 posts views Thread by Frances Del Rio | last post: by
36 posts views Thread by Rolloffle | last post: by
1 post views Thread by Richard | last post: by
1 post views Thread by Michael Carr | last post: by
26 posts views Thread by the.tarquin | last post: by
3 posts views Thread by jethro_uk | last post: by
3 posts views Thread by Peter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.