Searching a flexinode text field and including a ' in the query causes an SQL error similar to the following:

You have an error in your SQL syntax near 's grill%'OR
Where the search was: fred's grill

This is easily fixed by replacing ' with '' in the flexinode_page_table function:
Change:

    if ($edit['search']) {
      $sql .= " AND (n.title LIKE '%". $edit['search'] ."%'";
      foreach ($ctype->fields as $field) {
        $sql .= 'OR flexinode_'. $field->field_id .".textual_data LIKE '%". $edit['search'] ."%'";
      }
      $sql .= ')';
    }

To:

    if ($edit['search']) {
      $qsearch = str_replace("'", "''", $edit['search']);
      $sql .= " AND (n.title LIKE '%". $qsearch ."%'";
      foreach ($ctype->fields as $field) {
        $sql .= 'OR flexinode_'. $field->field_id .".textual_data LIKE '%". $qsearch ."%'";
      }
      $sql .= ')';
    }

However, this is almost certainly not the 'Drupal way' to do this - if anyone knows exactly which filter function this string needs to be run through to do this, please advise!

Thanks!
- Grugnog

Comments

mfb’s picture

This appears to have been fixed in current CVS of flexinode.

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)