database query issue

Permalink
Hello,

In my block controller I am trying to query a database and extract some info. However I keep getting the error: Warning: mysql_query() expects parameter 1 to be string

Please can someone advise why..?
My code is:

function getCategories() {
           $db = Loader::db();
           $db->Execute('select * from tablename');
           $checkresults = mysql_query($db);
           if($checkresults && mysql_num_rows($checkresults)>0)
           {
           $row = mysql_fetch_row ($checkresults);
           }
           else
           {
           if(!$checkresults)
           echo "Error in query: ".mysql_error();
           else
           echo "No record Found";
           }

 
citytech2 replied on at Permalink Reply
citytech2
What do you mean by these below lines:
$db->Execute('select * from tablename');
$checkresults = mysql_query($db);


do you know what you have written there. First you execute a query then run the DB library into mysql_query. Its strange, do you ever seen any code of concrete5. If its your first time, then go with the "Designer Content" Block. Install this add-on and create a simple block. Then follow through the pages, it will help you.
You can also go through the how-tos in the C5 marketplace as well.

Citytech
obaudains replied on at Permalink Reply
Thanks for the reply. I have used the designer content block as a guide, but i cant see what i need to do.

I need to create an array of my results from the query.

function getCategories() {
         $db = Loader::db();
         $q = "SELECT id, catname   FROM Config";
*How do i output the results into an array..?*


*How do i output the results into an array..?