Info
- 1 post
- 1 voice
- Started 2 years ago by grosbouff
- This topic is not resolved
problem with some queries
-
- Posted 2 years ago #
Hi, I've written a custom plugin to convert my old bbcode syntax [url=...]myurl[/url] to myurl>.
It worked for a large amount of posts but I still get a lot (also) of errors.Here's a query error :
UPDATE bb_posts SET post_text ='Bon c\'est sur que si on compare :rolleyes:\n\n[url=http://mabul.org/][img]http://apu.mabul.org/up/apu/2008/05/15/img-1933139bpys.jpg[/img][/url]\n\n[url=http://mabul.org/][img]http://apu.mabul.org/up/apu/2008/05/15/img-1933292biwg.jpg[/img][/url]' WHERE post_id = 114958As you see, the url tags have not been updated neither.
My function :
function replace_bbcode_urls() {
global $bbdb;$regex="#\[url ?=([^\[]*) ?] ?([^]]*) ?\[/url\]#";
$sql = "SELECT post_id, post_text FROM bb_posts WHERE post_text LIKE '%[url=%'";
$results = $bbdb->get_results($sql);
foreach($results as $row){
$new_monchamp = preg_replace($regex, "\2", $row->post_text);
$sql2 = sprintf("UPDATE bb_posts SET post_text ='%s' WHERE post_id = ".$row->post_id, mysql_real_escape_string($new_monchamp));if ($bbdb->query( $bbdb->prepare($sql2) )) {
//echo $row->post_id."
";
}else {
//echo "error processing post ".$row->post_id."
";
echo $sql2."
";
exit;
}}
}
Help would be appreciated.
Thanks ! -
You must log in to post.