MySQL query causing problems

I’ve trying to make too queries to different tables in the database but one query causes problems with the other.

This query works okay

usedb( $GLOBALS['country_modules'][$GLOBALS['code']]['db_ex'],"dbExter" );
$query="select id,name from symbols,symbols_map where symbol_id=symbols.id and visible=1 and id=".$GLOBALS['group_id'][$key]['id']." order by name";
$symbols_group=dbselect( $query,"dbExter" );

but if I then use this one too:

usedb( $GLOBALS['country_modules'][$GLOBALS['code']]['db_ex'],"dbExter" );
$query="select * from bullets where group_id=".$GLOBALS['group_id'][$key]['id']." and country like \"%".$GLOBALS['code']."%\" order by pos";
$bullets_group=dbselect( $query,"dbExter" );

then I get this error:

Query failed:

select * from bullets where group_id= order by pos

(You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘order by pos’ at line 1)

The second query works on it’s own without any errors though.

What’s the value of $GLOBALS[‘group_id’][$key][‘id’] when you get the problem?

Normally it’s the id number of that particular group so can be any number. Although when it doesn’t work it says that it’s empty

I was asking because it’s strange that the error message implies that the "and country like … " section of the query is missing. Or maybe that’s just the error reporting.

If I remove that then I still get the same error. I did wonder that myself but unfortunately it doesn’t make any difference.

I’m quite new to PHP/MySQL but it seems as though what happening is that after the first query/array it unsets the variables. I tried using it without $GLOBALS but that didn’t work either

try

echo $query

and make sure the query looks right.

Thanks, I’ll try that

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.