Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: DaLoE on July 25, 2020, 10:33:19 AM

Title: SubQuerys
Post by: DaLoE on July 25, 2020, 10:33:19 AM
Im trying to do a sub-query and I'm getting the $txt['database_error'] and $txt['try_again'] message. If I remove the modSettings lines, i get Hacking Attempt. I tried to remove lines 383-385 of my Subs-DB-mysql.php file but I'm still getting the same error.

global $modSettings;
$disableQueryCheckBack = $modSettings['disableQueryCheck'];
$modSettings['disableQueryCheck'] = true;

$queryexp = $smcFunc['db_query']('', "
SELECT *
FROM
    (
        SELECT *
        FROM {db_prefix}exped_seguim
        WHERE id_usuario = 83
    ) AS t
RIGHT JOIN {db_prefix}exped AS expe ON (t.id_exp =
expe.id_exped");


$modSettings['disableQueryCheck'] = $disableQueryCheckBack;


Is something wrong with the query? How can I do it? Maybe not using $smcFunc['db_query']? What should I do?



Thanks.
Title: Re: SubQuerys
Post by: vbgamer45 on July 25, 2020, 10:54:36 AM
You have it right with $modSettings['disableQueryCheck'] = true;
You have a bug with your SQL you are missing a  )
after RIGHT JOIN {db_prefix}exped AS expe ON (t.id_exp =
               expe.id_exped
Title: Re: SubQuerys
Post by: DaLoE on July 25, 2020, 11:03:27 AM
Quote from: vbgamer45 on July 25, 2020, 10:54:36 AM
You have it right with $modSettings['disableQueryCheck'] = true;
You have a bug with your SQL you are missing a  )
after RIGHT JOIN {db_prefix}exped AS expe ON (t.id_exp =
               expe.id_exped

Thanks... I can sleep now... Im very dumb

Thanks
Title: Re: SubQuerys
Post by: Arantor on July 25, 2020, 11:22:12 AM
I don't understand why this even needs a subquery in the first place.