I added some of these types of functions, into my own php functions, so I
can call them when I want to.
here is some examples:
if ( !$DEFINED_DATABASE )
{
$DEFINED_DATABASE = 1;
function DatabaseConnect()
{
if ( !($dbh) )
{
$dbh = mysql_pconnect("localhost","dbuser","dbpass");
mysql_select_db('[Database]');
}
return $dbh;
}
function Execute( $query, $dbh)
{
if (!($result))
{
file://echo"<br>query = $query";
if ( !($result = mysql_query( $query, $dbh )) )
{
printf( "ERROR IN EXECUTE: %s", mysql_error() );
exit();
}
return $result;
}
}
function GetArray($result)
{
if (isset($result))
{
$return = mysql_fetch_array( $result, MYSQL_ASSOC );
if ( (!(isset($return))))
{
printf( "Error in GetArray: %s", mysql_error() );
exit();
}
return $return;
}
}
function GetNumRows($result)
{
if (isset($result))
{
$return = mysql_numrows($result);
if ( (!(isset($return))))
{
printf( "Error in GetNumRows: %s", mysql_error() );
exit();
}
return $return;
}
}
function GetRecordCount($result)
{
if (isset($result))
{
// mysql_num_rows
$return = mysql_numrows($result);
if ( (!(isset($return))))
{
printf( "Error in GetNumRows: %s", mysql_error() );
exit();
}
return $return;
}
}
}
example code that uses these :
$query = "select
Min(ID) as Min
from Table";
// echo"<!-- \n query is here \n <br> = $query -->";
$result = Execute( $query, $dbh);
$count = GetRecordCount($result);
echo"Count = $count";
while ( $data = GetArray($result) )
{
$Field1 = $data[Field1];
$Field2 = $data[Field2];
echo"$Field1 - $Field2";
}
_____________________________________________
"Harpreet" <[EMAIL PROTECTED]> wrote in message
news:000f01c1571f$7a1d7c80$38c8a8c0@harpreet...
> Thank u all so much.
>
> Regards,
> Harpreet Kaur
> Software Developer
> Crispin Corporations Inc.
>
>
>
> -----Original Message-----
> From: Rick Emery [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 17, 2001 11:06 AM
> To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
> Subject: [PHP-DB] RE: eof
>
>
> mysql_num_rows($result)
>
> -----Original Message-----
> From: Harpreet [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 17, 2001 10:13 AM
> To: 'Rick Emery'; [EMAIL PROTECTED]
> Subject: eof
>
>
> How can one check if no records r returned by a query?
>
> For eg.,
> <?php
> $sqlstr="Select * from msg_operator_tbl where type= 'U' or type = 'MC'
order
> by send_date desc";
> $result = mysql_query($sqlstr);
> ?>
>
> How can i check if mssql_query returned ne rows?
>
> regards,
> Harpreet Kaur
> Software Developer
> Crispin Corporations Inc.
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]