Topic: $db->query() returns error (custom code)

I'm using FluxBB's $db->object (v1.2.20) in my site's code to make it cleaner and somewhat easier to read.

    $console['url'] = safeUrl($_GET['cname']);
    $result = $db->query('SELECT cid, cname FROM consoles WHERE cname_url='.$console['url'].' LIMIT 1') or error('Unable to fetch console info', __FILE__, __LINE__, $db->error());
    list($console['id'], $console['name']) = $db->fetch_row($result);

everytime it spits out the error with no more information attached to it. no mysql_error, nothing.  pun's config is called by index.php which uses switch to include my pages. i can use: in the same script and it works fine.  the fields cid, cname and cname_url all exist and $console['url'] has a valid value.  is there something in pun's config that doesn't allow it to query any table other than it's own?

$result = $db->query('SELECT id, username, realname FROM '.$db->prefix.'users WHERE group_id='.PUN_ADMIN.' ORDER BY username', true) or error('Unable to fetch staff list', __FILE__, __LINE__, $db->error());
    while ($staff = $db->fetch_assoc($result))
        echo $staff['id'];

what would i have to do to make it work right?

thanks in advance
-xP

P.S. I don't know whether or not it should go here or in 1.2's support forum, so I chose here because although it deals w/ flux's code, it's not directly related to flux's scripts other than it's functions (which in general work fine)

Last edited by xPlozion (2008-08-07 21:54:23)

eVGA 122-CK-NF68, Intel Core 2 Quad Q6600, OCZ 4GB DDR2, XFX 8400GS 512MB
OS: Arch Linux x86_64 (2008.06) / Windows XP

Re: $db->query() returns error (custom code)

Would this table be in another database perchance?

Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Re: $db->query() returns error (custom code)

no, it's the same database, just the fluxbb has the prefix flux_ where the rest of the site has no prefix...

eVGA 122-CK-NF68, Intel Core 2 Quad Q6600, OCZ 4GB DDR2, XFX 8400GS 512MB
OS: Arch Linux x86_64 (2008.06) / Windows XP

Re: $db->query() returns error (custom code)

Have you enabled debug mode?

Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Re: $db->query() returns error (custom code)

File: /home/jburke/public_html/sources/codes.php
Line: 11

FluxBB reported: Unable to fetch console info

Database reported: Unknown column 'xbox360' in 'where clause' (Errno: 1054) 

basically, the query should look like this when the variables are passed

'SELECT cid, cname FROM consoles WHERE cname_url=xbox360 LIMIT 1'

MySQL DB:
cid     cname     cname_url     featured
1     XBOX 360     xbox360     1

eVGA 122-CK-NF68, Intel Core 2 Quad Q6600, OCZ 4GB DDR2, XFX 8400GS 512MB
OS: Arch Linux x86_64 (2008.06) / Windows XP

Re: $db->query() returns error (custom code)

ok, found out what was wrong.  thank you for pointing me in the right direction (w/ debug mode and all).

you guys have a great support forum, everyone (even those unaffiliated) helps everyone else.  that is why flux will thrive!

eVGA 122-CK-NF68, Intel Core 2 Quad Q6600, OCZ 4GB DDR2, XFX 8400GS 512MB
OS: Arch Linux x86_64 (2008.06) / Windows XP