SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    regex mysql not working in php

    the sql syntax is working via mysql-front but when i try to echo out the results in php, they're all zero. the sql query below finds titles that match the pattern "copy (#) of $survey_title"

    PHP Code:
    include ("common_db.inc.php");
    $title "COPY (1) of You in 10 years";
    $regex_title eregi_replace('^(copy \()[0-9]*\) of ','',$title);
    echo 
    $regex_title;
    $uid 4;

    $SQL 'SELECT title, title regexp "^(copy \\\\\()[0-9]*(\\\\\) of '.$regex_title.')$" as regex
                    FROM survey
                    WHERE rel_uid = '
    .$uid;
    echo 
    "<br>".nl2br($SQL).'<br>';

    $result mysql_query($SQL);

    while (
    $sql_assoc mysql_fetch_assoc($result))
    {    
        echo 
    $sql_assoc['title'].' | ';
        echo 
    $sql_assoc['regex'].'<br>';    

    output
    Code:
    You in 10 years
    SELECT title, title regexp "^(copy \()[0-9]*(\) of You in 10 years)$" as regex
    FROM survey
    WHERE rel_uid = 4
    Title2 | 0
    Survey1 (All Options) | 0
    survey4 | 0
    survey5 | 0
    Real Survey | 0
    asdf | 0
    You in 10 years | 0
    copy (1) of You in 10 years | 0
    copy (2) of You in 10 years | 0
    copy (1) of asdf | 0
    Last edited by GeekSupport; Dec 19, 2002 at 18:39.

  2. #2
    SitePoint Evangelist GeekSupport's Avatar
    Join Date
    May 2002
    Location
    Southern California
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed
    PHP Code:
    include ("common_db.inc.php");
    $title "COPY (1) of You in 10 years";
    $regex_title eregi_replace('^(copy \()[0-9]*\) of ',null,$title);
    echo 
    '|'.$regex_title.'|';
    $uid 4;

    $SQL 'SELECT title, title regexp "^(copy \\\\\\\()[0-9]*(\\\\\\\) of '.$regex_title.')$" as regex
                    FROM survey
                    WHERE rel_uid = '
    .$uid;


    echo 
    "<br>".nl2br($SQL).'<br>';

    $result mysql_query($SQL);

    while (
    $sql_assoc mysql_fetch_assoc($result))
    {    
        echo 
    $sql_assoc['title'].' | ';
        echo 
    $sql_assoc['regex'].'<br>';
        



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •