 |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6  | This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 14th, 2004, 10:55 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
A new chapter 15 problem with BBcodes
I've discovered this problem after I made a fix for the compatability problems I had using the forum on mySQL version 3.23.58. Read my posting (Chapter 15 problems) a few days ago.
This problem is with the bbcode function in functions.php
Again! This was a compatability problem, but this time it's PHP. I'm running PHP 4.1.2 and html_entity_decode() is a PHP 4.3 function.
Well I've tried to build a fix for it using:
function unhtmlentities($string)
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function bbcode($data) {
...
$bbcode['tpl'][] =
"§" . unhtmlentities($row['template'],ENT_QUOTES). "§i";
$bbcode['rep'][] =
unhtmlentities($row['replacement'],ENT_QUOTES);
}
...
Here's my complete code:
function unhtmlentities($string)
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
function bbcode($data) {
$sql = "SELECT * FROM forum_bbcode";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) {
$bbcode['tpl'][] =
"§" . unhtmlentities($row['template'],ENT_QUOTES). "§i";
$bbcode['rep'][] =
unhtmlentities($row['replacement'],ENT_QUOTES);
}
$data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
$count = 1;
while (($data1 != $data) and ($count < 4)) {
$count++;
$data = $data1;
$data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
}
}
return $data;
}
And here's the original function:
function bbcode($data) {
$sql = "SELECT * FROM forum_bbcode";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) {
$bbcode['tpl'][] =
"̤̉" . html_entity_decode($row['template'],ENT_QUOTES). "̤̉i";
$bbcode['rep'][] =
html_entity_decode($row['replacement'],ENT_QUOTES);
}
$data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
$count = 1;
while (($data1 != $data) and ($count < 4)) {
$count++;
$data = $data1;
$data1 = preg_replace($bbcode['tpl'],$bbcode['rep'],$data);
}
}
return $data;
}
Now here's my problem:
I'm getting this error on each thread's sub thread:
Warning: Compilation failed: missing terminating ] for character class at offset 22 in /removed/forum/functions.php on line 355
Can anyone explain why I would have a missing (])
PS. I don't know why the original has (ÃâÃ) but that's not my problem!
|
|

August 14th, 2004, 01:24 PM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've managed to solve the problem I mentioned earlier!
The problem wasn't with the script I wrote. The script works fine!
What I'd done was to systematically replace all the single quotes in admin.php (and all the pages) with escaped double quotes (\"). Well! doing this in the form values meant that the wrong characters were being escaped.
So I corrected my code to be:
"<input class=\"mono\" type=\"text\" name=\"bbcode_t". $k . "\" " .
"value='" . $v['template'] . "' size=\"32\">" .
"</td>\n<td>" .
"<input class=\"mono\" type=\"text\" name=\"bbcode_r". $k . "\" " .
"value='" . $v['replacement'] . "' size=\"32\">" .
Everything now works fine!
|
|

September 11th, 2004, 11:11 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Phil, thank you so much for posting this and your other chapter 15 fixes.
I am running PHP 4.3.8 and MySQL 3.23.56 and so I had the obvious problems from not having MySQL 4. And I also had the problem mentioned in this thread, but your first post fixed it.
Thanks so much!!! ;)
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| chapter 15 problem |
golfbird |
BOOK: Beginning Visual C++ 6 |
7 |
September 9th, 2008 12:29 PM |
| Chapter 16 BBCodes |
phlop |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
2 |
June 12th, 2008 04:24 AM |
| Chapter 15 problem |
PhilM |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
16 |
March 10th, 2008 02:46 PM |
| Chapter 15 Problem |
rsearing |
BOOK: Beginning ASP.NET 2.0 and Databases |
3 |
October 12th, 2006 02:59 PM |
| Chapter 15 Search Problem |
PhilM |
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 |
2 |
November 2nd, 2004 05:08 PM |
|
 |