Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 07:24 pm EDT

Geeklog Forums

what'm i doing wrong?


bwaynef

Anonymous
Text Formatted Code
function phpblock_happytimes ()
{
    $sql = "SELECT SUM(times) FROM table WHERE DATE_SUB( CURDATE( ) , INTERVAL 31 DAY ) <= date GROUP BY WEEK(date) DESC LIMIT 4";
    return DB_query($sql);
}
 


I get "Resource id #133" from the Home topic (125, 124, & 120 on other topics) in that block.

The SQL is legit and should return 2 rows of 1 field (does in phpMyAdmin). Admittedly I know little about php. Can anyone help?

Thanks
 Quote

Status: offline

THEMike

Forum User
Moderator
Registered: 07/25/03
Posts: 141
Location:Sheffield, UK
DB_query either returns false, or a result set resource. It does not return any HTML or anything that can be directly evaluated to a meaningful string.

You will need to write some code to loop through all the results in that result set and format them up as HTML. Using DB_numResults (hmm not 100% sure that's the right function name) and DB_fetchArray.
 Quote

bwaynef

Anonymous
You mention DB_. Where can I find out more about those functions??

Thanks for your help,
 Quote

Status: offline

THEMike

Forum User
Moderator
Registered: 07/25/03
Posts: 141
Location:Sheffield, UK
lib-database.php in the system directory of your geeklog install.
 Quote

bwaynef

Anonymous
Thanks.

I got it working already. I'll have to read thru that file and get this figured out. Thanks for the pointers though.

 Quote

All times are EDT. The time is now 07:24 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content