Warning: Unexpected character in input: ''

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Warning: Unexpected character in input: ''

Post by Steveo31 »

I've done all the searches and tried everything everyone threw at me, no luck getting this thing fixed.

Code: Select all

$output = preg_replace('|\[div](.*?)\[/div]|ise',"str_replace('<br />', null, "<div class='div_code'>".highlight_string('\\1',true)."</div>")", $row['body']);
    
echo nl2br(stripslashes($output));
Gives me

Code: Select all

$sql = mysql_query(
Warning: Unexpected character in input: '' (ASCII=92) state=1 in /home2/theobvi/public_html/includes/content/articles.php(31) : regexp code on line 16
It highlight_strings part of it, then throws this error, then the rest of the highlighted code is messed, i.e. quotes not being closed, so it's all red.

Any ideas?
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

Post by potsed »

Code: Select all

$output = preg_replace('|\&#1111;div](.*?)\&#1111;/div]|ise',"str_replace('<br />', null, "<div class='div_code'>".highlight_string('\1',true)."</div>")", $row&#1111;'body']);
try using

Code: Select all

$output = preg_replace('|\&#1111;div](.*?)\&#1111;/div]|ise',"str_replace(''<br />'', null, "<div class='div_code'>".highlight_string('\1',true)."</div>")", $row&#1111;'body']);
putting '' in after instead of just '
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Hmm.. is the forum getting rid of the backslash, cause it looks the same to me...

In any case, combinations of backslashes aren't working. An @ takes the error out, but the coloring is still askew.


ex:

http://www.theobviousreasons.com/index. ... asic+MySQL
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

bumparoo
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

the @ will take out the error as php uses it to suppress errors.
I would start by dismatiling your string and slowly rebuild it to see if there is a quote that is being missed or unescaped.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Right, yea at least without the error people could see the code uninterrupted. Just a temp measure.

I'll try that and let you know. Thanks.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Ok, well the reason this thing keeps exploding on me is the " mark. It has no probs with ', but the second a " comes in, kaboom.

It's obviously because the second param of the preg_replace is in double quotes... any way around it?

Code: Select all

$output = preg_replace('|\[div](.*?)\[/div]|ise',"str_replace('<br />', null, "<div class='div_code'>".highlight_string('\\\\1',true)."</div>")",
Post Reply