Skip to:
Content
Pages
Categories
Search
Top
Bottom

problem with some queries


  • grosbouff
    Participant

    @grosbouff

    Hi, I’ve written a custom plugin to convert my old bbcode syntax myurl 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:nnimg-1933139bpys.jpgnnimg-1933292biwg.jpg' WHERE post_id = 114958

    As 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 be logged in to reply to this topic.
Skip to toolbar