Question: This is in PHP. I am accepting a string in which user enters regular expression and I need to pass this in Select query to extract and display file names which matches the expression.

For eg.if user enters `*.pdf`, it should return all pdf files; if user enters ^temp, then all files starting with temp should be displayed and so on.

My string is reaching out properly, but i am not able to form the query.
I am storing a string in $parameter and the query is like this:

```
$result=mysql_query("select filename from fileinfo where filetype REGEXP '$parameter'");

```

Please help me out.

Answer: 
There are 2 problems I see

1. You're using glob syntax (e.g. \*.pdf) instead of an correct regexp syntax. `'.*\\.pdf'` would be a valid regexp equivalent of `'*.pdf'` (which should always fail, since it's invalid)
2. It looks like you are incorrectly testing FILETYPE instead of FILENAME? Try this instead:

`$result=mysql_query("select filename from fileinfo where filename REGEXP '{$parameter}'");`

Finally, try echoing your SQL to ensure you're running the query you think you are. You may have some escaping issues.
Try this

```
$result=mysql_query("select filename from fileinfo where filetype REGEXP '".$parameter."'); 

```