Retrieving query from MSSQL Table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a form where I can submit a Query to be run against a MSSQL 2000 Server.
The query is stored correctly in a text (DataType) column. I can
retrieve it echo it back to the screen, copy-n-paste into Query
Analyzer and the query works.

What I cannot do is get the query to be returned from the recordset
and used to build a new recordset. Confused?

    function preview_report(){
            //Get the query
	    $s = "SELECT rptsql \n";
    	    $s .= "FROM rpt_mas\n";
    	    $s .= "WHERE id={$_POST['frm_rptid']}\n";
    	    $r = $this->db->Execute($s);
    	    $r_arr = $r->GetArray();
    	    $sql1 = $r_arr[0][0]; //I can echo this to the screen and run
it in Query Analyzer
    	    $sql2 = "SELECT id, rptname, rptdesc, rptfile, rpttype,
rptsql FROM rpt_mas";

    	if($sql!=""){
    		$this->xq = $sql;
    		$r = $this->db->Execute($sql1);//This doesn't work
    		$r = $this->db->Execute($sql2);//This does work
    	}
    }

$sql1 & $sql2 are one and the same. Any ideas what I'm missing?

Thanks,
Mike Smith

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux