Page 1 of 1

querying mssql database

Posted: Wed Jun 21, 2006 4:18 pm
by kmeen
The following piece of code does not work, can someone tell me why? I see an error in the log saying exit bus signal error(10) and in IE I get page cannot be displayed error.

$SQL = "BEGIN SELECT tblfirsttable.varCharData , tblSecondtable.floatData from tblfirsttable, tblSecondtable";
$query_rslt = mssql_query($SQLl);
$numrows = mssql_num_rows($query_rslt);
echo $numrows;

The strangest thing is that when I swap the selec return types(first select tblSecondtable.floatData, tblfirsttable.varCharData) it works fine, as shown below.

$SQL = "BEGIN SELECT tblSecondtable.floatData, tblfirsttable.varCharData from tblfirsttable, tblSecondtable";
$query_rslt = mssql_query($SQLl);
$numrows = mssql_num_rows($query_rslt);
echo $numrows;

Can someone please explain this behavior.

Thanks.

- Meena.


[/b]

Posted: Wed Jun 21, 2006 4:37 pm
by bdlang
I can't say for certain the SQL statement is correct, since I'm unaware of any MSSQL specifics, but I can tell you your call to mssql_query() is actually using an unknown variable $SQLl rather than the statement variable $SQL. Simple typo, methinks.

Posted: Wed Jun 21, 2006 4:44 pm
by kmeen
Sorry that was a typo I made for this post the script really is $SQL. Let me post my script again in order to make it clear:

$SQL = "BEGIN SELECT tblfirsttable.varCharData , tblSecondtable.floatData from tblfirsttable, tblSecondtable";
$query_rslt = mssql_query($SQL);
$numrows = mssql_num_rows($query_rslt);
echo $numrows;

The strangest thing is that when I swap the selec return types(first select tblSecondtable.floatData, tblfirsttable.varCharData) it works fine, as shown below.

$SQL = "BEGIN SELECT tblSecondtable.floatData, tblfirsttable.varCharData from tblfirsttable, tblSecondtable";
$query_rslt = mssql_query($SQL);
$numrows = mssql_num_rows($query_rslt);
echo $numrows;


Sorry about that. Any help is appreciated.