#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    16
    Rep Power
    0

    Warning: Unexpected character in input: '' (ASCII=92) state=1


    Hi.

    I'm using the highlight_string function in one of my scripts to output highlight some PHP code, but in a couple of places, I get the error message "Warning: Unexpected character in input: '' (ASCII=92) state=1 in...".

    For example, what I would expect to see output as this:

    PHP Code:
    <?php
    $test 
    "This is a test";
    ?>
    ...is actually been output as this:

    PHP Code:
    <?php

    $test 


    WarningUnexpected character in input'' (ASCII=92state=1 in <etc etc etc>

    "This is a test";

    ?>
    I don't really understand what could be causing this, and would welcome any advice you could offer.

    Thank you.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    28
    Rep Power
    0
    Well, ascii 92 is a "\" character, which has special meaning in php. Remember that to actually display a "\" character, you need to type "\\".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    16
    Rep Power
    0
    Hmm, that's confusing me a little.

    The code I want to highlight is stored in a variable named $output. The reason I'm confused is because I have the line stripslashes($output); before highlight_string($output);, so surely the offending \ (before the first " mark from the looks of the error) should have been removed should it not? Or am I misunderstanding the way in which the stripslashes function works?

    Can you possibly give me some advice as to what to do next?

    Thanks for the help so far.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    28
    Rep Power
    0
    You will likely need to remove the stripslashes, or even use addslashes instead. I'd have to see the code to make sure, but try that.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    16
    Rep Power
    0
    When I removed the stripslashes line, the error above disappeared, but a different one appeared. However, the new error was caused by a bug elsewhere in the script it seems, which has now been fixed.

    Thanks for all of your help. I couldn't have done this without it.

IMN logo majestic logo threadwatch logo seochat tools logo