SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast Sirus's Avatar
    Join Date
    Sep 2001
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unterminated string constant

    What exactly is an unterminated string constant, and how do I get rid of it?

    <a href="#" onclick="window.open('https://www.paypal.com/cart/add=1&business=Sirus%40peoplepc.com&item_name=<? echo "$item" ?>&amount=<? echo "$output[0]" ?>&item_number=<? echo "$output[3]" ?>','cartwin','width=600,height=400,scrollbars,location,resizable,status');">

    That is the line it is happening on.

    If I remove the amount=<? echo "$output[0]" ?> and replace it with amount=2 then it works just fine. How can I fix this?

    Also, sorry I have been asking so many questions lately.

    -Jeff

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't apologise for asking questions that's why we are all here

    How are you assigning values to $output?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Enthusiast Sirus's Avatar
    Join Date
    Sep 2001
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <? $output = file("$dir/$item"); ?>

    $output[0] has a value of 5.00

    Is it the decimal that is causing it?

    -Jeff

  4. #4
    SitePoint Enthusiast Sirus's Avatar
    Join Date
    Sep 2001
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I know why now.

    The string has a line break in it. How can I strip the line breaks from a string, so it is all one line?

    Thanks,
    -Jeff

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not getting any errors from your code so it must be something to do with the way you are assigning the values to $output. Can you post the whole code please

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Sirus
    Ok, I know why now.

    The string has a line break in it. How can I strip the line breaks from a string, so it is all one line?

    Thanks,
    -Jeff
    Like this:

    PHP Code:
    $string str_replace("\n"""$string); 
    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  7. #7
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Sirus
    Ok, I know why now.

    The string has a line break in it. How can I strip the line breaks from a string, so it is all one line?

    Thanks,
    -Jeff
    That's right, when you use the file() function, each array element contain a line of the file, incluiding the line, break.
    There are several way to do that. I believe the simple one is using the function chop(), which only remove the last character in a string.

  8. #8
    SitePoint Enthusiast Sirus's Avatar
    Join Date
    Sep 2001
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks everyone.

    I just did something like this:
    $p = str_replace("/n", "", $p);

    and it seemed to work, so I am happy.

    I won't be asking any more questions for a while because I am finished! Yay!

    -Jeff

  9. #9
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Paul, would chop() consider \n one character or 2?
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  10. #10
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •