Re: Retrieving query from MSSQL Table

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

 






On Wed, April 27, 2005 1:29 pm, Mike Smith said:
> 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;

if ($sql1 == $sql2){
  echo "They really are the same...<br />\n";
}
else{
  echo "They're not REALLY the same!<br />\n";
  for ($i = 0; $i = strlen($str1); $i++){
    $c1 = $str1[$i];
    $c2 = $str2[$i];
    $o1 = ord($c1);
    $o2 = ord($c2);
    if ($c1 != $c2){
      echo "At position $i, c1 is $c1 ($o1), and c2 is $c2 ($o2)<br />\n";
    }
  }
}

>     		$r = $this->db->Execute($sql1);//This doesn't work

echo mssql_error(); //Or whatever this should be.

>     		$r = $this->db->Execute($sql2);//This does work
>     	}
>     }
>
> $sql1 & $sql2 are one and the same. Any ideas what I'm missing?

I'm betting dollars to doughnuts that you've got a newline at the end of
$sql1 which is messing you up.



-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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