View Full Version : Resource id #17
Decode
07-06-2008, 04:13 PM
When i do
$sql = "SELECT COUNT(username) FROM user_sys";
$registered = mysql_query("$sql");
echo $registered;
Its ment to cound the number of records in the username row in the user_sys table, but it just displays "Resource id #17". Ive never used SQL before so i dont know how to fix it :(
+rep for help
Agnostic Bear
07-06-2008, 04:19 PM
When i do
$sql = "SELECT COUNT(username) FROM user_sys";
$registered = mysql_query("$sql");
echo $registered;
Its ment to cound the number of records in the username row in the user_sys table, but it just displays "Resource id #17". Ive never used SQL before so i dont know how to fix it :(
+rep for help
$sql = mysql_query( "SELECT COUNT(`username`) FROM `user_sys`" );
$fetch = mysql_fetch_array( $sql );
echo( $fetch[0] );
should do it not used count() much so I don't know what it returns as
Decode
07-06-2008, 04:24 PM
$sql = mysql_query( "SELECT COUNT(`username`) FROM `user_sys`" );
$fetch = mysql_fetch_array( $sql );
echo( $fetch[0] );
should do it not used count() much so I don't know what it returns as
It works :) Thanks +rep.
Independent
09-06-2008, 08:12 AM
That seems pretty complex, there's a pre-made function for that already
mysql_list_fields.. This is what I did (After the database was connected)
$user = mysql_list_fields("nivade_core", "peepz"); // Database then Table.
and the same for comments
Agnostic Bear
09-06-2008, 10:17 AM
That seems pretty complex, there's a pre-made function for that already
mysql_list_fields.. This is what I did (After the database was connected)
$user = mysql_list_fields("nivade_core", "peepz"); // Database then Table.
and the same for comments
That would list fields, not count.
Independent
09-06-2008, 10:51 AM
That would list fields, not count.
Oh, I thought that he was counting fields.
Agnostic Bear
09-06-2008, 11:06 AM
Oh, I thought that he was counting fields.
He is, listing fields gives the field names, not the count of them.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.