This topic is locked
[SOLVED]

 db_num_rows question

12/12/2012 4:42:50 PM
PHPRunner General questions
W
wildwally author

Is there any particular way this should be used?
I'm trying to determine if there were any results from a query - if so then fetch the array and distribute into a table with While.



$sqlresult = db_query($sqlquery,$conn);

if(db_num_rows($sqlresult) > 0)

{

//------other code prior to table--------//

while ($row = db_fetch_array($sqlresult))

{

//-----more code........


but this is not working getting undefined function
Fatal error: Call to undefined function db_num_rows() ........
Tried using mssql_num_rows and get error too.
mssql_num_rows(): supplied argument is not a valid MS SQL-result resource

Sergey Kornilov admin 12/12/2012

Simply use the following:



$sqlresult = db_query($sqlquery,$conn);

//------other code prior to table--------//

while ($row = db_fetch_array($sqlresult))

{

//-----more code........
W
wildwally author 12/13/2012

I'm trying to evaluate if any results were found in the query to determine whether or not to run a bit of code prior to the WHILE loop.

C
cgphp 12/13/2012

The correct function name is db_numrows:

$sqlresult = db_query($sqlquery,$conn);

if(db_numrows($sqlresult) > 0)

{

//------other code prior to table--------//

while ($row = db_fetch_array($sqlresult))

{

//-----more code........
W
wildwally author 12/13/2012



The correct function name is db_numrows:

$sqlresult = db_query($sqlquery,$conn);

if(db_numrows($sqlresult) > 0)

{

//------other code prior to table--------//

while ($row = db_fetch_array($sqlresult))

{

//-----more code........



Fatal error: Call to undefined function db_numrows() in

C
cgphp 12/13/2012

Where are you using that code?

W
wildwally author 12/13/2012



Where are you using that code?


Custom page/file within PHPR. I'm able to use other db functions built into PHPR with no problem. And when you start to type out the db function there is one in the system for db_num_rows just like the one I found for mssql_num_rows.