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
Steveo31
Forum Contributor
Posts: 416 Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA
Post
by Steveo31 » Sat Nov 20, 2004 1:17 am
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?
potsed
Forum Commoner
Posts: 50 Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa
Post
by potsed » Sat Nov 20, 2004 4:23 am
Code: Select all
$output = preg_replace('|\їdiv](.*?)\ї/div]|ise',"str_replace('<br />', null, "<div class='div_code'>".highlight_string('\1',true)."</div>")", $rowї'body']);
try using
Code: Select all
$output = preg_replace('|\їdiv](.*?)\ї/div]|ise',"str_replace(''<br />'', null, "<div class='div_code'>".highlight_string('\1',true)."</div>")", $rowї'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 » Sat Nov 20, 2004 1:37 pm
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 » Sun Nov 21, 2004 4:42 pm
bumparoo
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Mon Nov 22, 2004 2:54 am
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 » Tue Nov 23, 2004 1:22 am
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 » Fri Nov 26, 2004 4:50 pm
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>")",