Bizarre problem when trying to write to a csv

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • compuv
    New Member
    • Aug 2007
    • 2

    #1

    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:

    [code=php]$CSVDIR = "/home/myaccount/public_html/csvdir"; // directory for csv files; empty string to
    // disallow csv files
    $CSVSEP = ","; // comma separator between fields (columns)
    $CSVINTSEP = ";"; // semicolon is the separator for fields (columns)
    // with multiple values (checkboxes, etc.)
    $CSVQUOTE = '"'; // all fields in the CSV are quoted with this character;
    // default is double quote. You can change it to
    // single quote or leave it empty for no quotes.
    //$CSVQUOTE = "'"; // use this if you want single quotes
    $CSVOPEN = ""; // set to "b" to force line terminations to be
    // kept as $CSVLINE setting below, regardless of
    // operating system. Keep as empty string and
    // leave $CSVLINE unchanged, to get text file
    // terminations for your server's operating system.
    // (Line feed on UNIX, carriage-return line feed on Windows).
    $CSVLINE = "\n"; // line termination for CSV files. The default is
    // a single line feed, which may be modified for your
    // server's operating system. If you want to change
    // this value, you *must* set $CSVOPEN = "b".[/code]


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

    [code=php]{
    global $TARGET_URLS;

    foreach ($TARGET_URLS as $s_prefix)
    if (!empty($s_pref ix) &&
    strtolower(subs tr($s_url,0,str len($s_prefix)) ) ==
    strtolower($s_p refix))
    return (true);
    return (false);
    }[/code]


    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.

    Dave
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Replace && with && in the below code.
    [PHP]if (!empty($s_pref ix) &&a mp;
    strtolower(subs tr($s_url,0,str len($s_prefix)) ) ==
    strtolower($s_p refix))[/PHP]
    It will become
    [PHP]if (!empty($s_pref ix) &&
    strtolower(subs tr($s_url,0,str len($s_prefix)) ) ==
    strtolower($s_p refix))[/PHP]

    Comment

    • compuv
      New Member
      • Aug 2007
      • 2

      #3
      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.

      Dave

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        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.

        Comment

        Working...