Retrieving query from MSSQL Table

From: Date: Wed, 27 Apr 2005 20:29:30 +0000
Subject: Retrieving query from MSSQL Table
Groups: php.general 
Request: Send a blank email to php-general+get-214042@lists.php.net to get a copy of this message
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

« previous php.general (#214042) next »