PHP/ MSSQL & a stored procedure...

Discussion in 'Web Design and Development' started by ChoMomma, Jun 11, 2007.

  1. ChoMomma macrumors 6502


    Anyone have experience with PHP, MSSQL and excuting a stored procedure?

    I have Mac-mini running a small corporate intranet site, I have installed PHP 5 with FreeTDS so that I can access MSSQL databases that run on other company servers.

    My problem is that I want I have a search form that queries a database fine, but I have a stored procedure that modifies the input on one field to bounce it off of a list of known abbreviations (ex: OS = Operating System). The stored procedure takes the input of the field and then outputs a string like db.field LIKE %Operating% OR db.field LIKE %System% OR db.field LIKE %OS%

    That string needs to be put into the existing database query.

    $sql = mssql_query("SELECT * FROM DBTable WHERE $storedprocedure ORDER BY x DESC");

    However when I try to drop my string into that query it always complains about syntax error before ORDER.

  2. jeremy.king macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
    To exec a stored proc, you will need to use the following functions


    Problem is this will require two SQL calls, one for the stored proc and one for the query. The only way you could do it with one query is to write another stored proc that references the first and executes your SELECT statement.

Share This Page