List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:March 28 2006 8:59pm
Subject:Re: Li'l problem with count()
View as plain text  
Sandy,

>$result = mysql_query($sql,$lnk);
>...
>Why this leads to 'ressource id #10' instead of the flies count ?
>The query gives the actual count if I use it in a line command !!

You've been fooled by your variable name. For SELECT, SHOW, DESCRIBE or 
EXPLAIN, mysql_query() returns a resource on success, ||for other type 
of SQL statements (UPDATE, DELETE etc) mysql_query() returns |TRUE| on 
success, and they both return |FALSE| on error.

PB

-----

> Hi
>
>
>
> <p>Flies in pot = <?=flies();?> </p>
>
> function flies(){
> $sql = 'select count(*) from flies';
> $lnk = mysql_connect('localhost','root','123456');
> $db = mysql_select_db('moar',$lnk);
> $result = mysql_query($sql,$lnk);
> mysql_free_result($result);
> mysql_close($lnk);
> return $result;
> }
>
>
> Why this leads to 'ressource id #10' instead of the flies count ?
> The query gives the actual count if I use it in a line command !!
>
> thanks
>
>
>
>
>
>   

Attachment: [text/html]
No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.385 / Virus Database: 268.3.2/294 - Release Date: 3/27/2006
Thread
Li'l problem with count()Sandy28 Mar
  • Re: Li'l problem with count()Peter Brawley28 Mar
RE: Li'l problem with count()Jay Blanchard28 Mar
  • Re: Li'l problem with count()Sandy28 Mar
  • Re: Li'l problem with count()Sandy28 Mar
RE: Re: Li'l problem with count()Jay Blanchard29 Mar