php - sql query returning string instead of integer while using COUNT -


$query_products_records="select @myint=count(*) products"; $result_query_products_records=mysql_query($query_products_records); echo 'table records ...'.$result_query_products_records; 

i used above query count of rows in table, got

resource id #4 on echo.

i have 3 records in table.

mysql_query creates resource.

that resource should used mysql_fetch_row().

mysql_fetch_row(mysql_query($query)); 

for example. or use in while loop extract more 1 result.

ps: consider using mysqli extension on mysql. deprecated.

the working code

$result_data = mysql_fetch_assoc(mysql_query("select count(*) c products")); echo 'table records ...'. $result_data['c']; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -