Combining SUBSTRING and LOCATE functions

street9009
street9009 used Ask the Experts™
on
SELECT SUBSTRING(Data, LOCATE('mssql_',Data), (LOCATE(')', Data) - LOCATE('mssql_',Data) +1)   FROM `mssql` WHERE 1

Open in new window


Basically I created a MySQL table that houses records that have PHP lines of code with MSSQL Function calls in them. So the records may look like this:

AutoID | Data
1          |  $connection = mssql_connect($server, $user, $pwd);
2          |  $result = mssql_query($query, $mssqlconn);

Something like that. Basically I am just trying to get the mssql_ function and its parameters returned in a result (so the first record would return "mssql_connect($server, $user, $pwd)". I *thought* the above query would do it, but it's giving me an error.

Anyone know what I'm doing wrong?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
Commented:
SELECT SUBSTRING(Data, LOCATE('mssql_',Data), (LOCATE(')', Data) - LOCATE('mssql_',Data) +1))   FROM `mssql` WHERE 1

You're just missing a closing parenthesis

EDIT: It should be +2 at the end if you want to include the semicolon

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial