Fog Creek Software
Discussion Board




PHP and ADODB -- Could anyone help?

Okay, I try not to use JoS as a help desk, tonight I make an exception.

I have a function which is getting stuck on an if/else, I think the problem has to do with I have this $rec stuck there which seems to do absolutely nothing (I confess, this code worked fine in VBScript until I ran it through a VBtoPhp converter, it now has some minor issues)
I am wanting to check that the number of records in the recordset $rec is 1.

// $rec is of type "ADODB.Recordset"
$rec_query=mysql_query(("SELECT count(*) FROM license_key WHERE lic_key =".$str),$objconn);   
$rec=mysql_fetch_array($rec_query);
if (mysql_query("count(*)")==1)


Any advice is much appreciate.

Aussie Chick
Tuesday, August 10, 2004

Thanks figured it out:

// $rec is of type "ADODB.Recordset"
$rec_query=mysql_query(("SELECT count(*) FROM license_key WHERE lic_key =".$str),$objconn);   
$rec=mysql_fetch_array($rec_query);
if ($rec[0]==1)
{

Sometimes it just helps to talk....

Aussie Chick
Tuesday, August 10, 2004

You might also want to get rid of the reference to ADODB.Recordset in your comment. It's most definitely not an ADODB.Recordset.

Clay Dowling
Tuesday, August 10, 2004

noted.

Aussie Chick
Tuesday, August 10, 2004

<i>I am wanting to check that the number of records in the recordset $rec is 1.</i>

$rec is returned from mysql_fetch_array().  mysql_fetch_array() returns an array of a single row from the query.  So if the query returns multiple rows, mysql_fetch_array() will only fetch one at a time (you need to put it in a loop to get the rest).

And yeah, none of that stuff has anything to do with ADODB, which is an abstraction layer for the php mysql_* functions.

saberworks
Tuesday, August 10, 2004

The new comment will be:

// http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=173143

www.MarkTAW.com
Wednesday, August 11, 2004

*  Recent Topics

*  Fog Creek Home