Advertisement:

'No Database Selected', every time i want to install MODs

Aloittaja poda19, lokakuu 17, 2012, 02:22:00 IP

« edellinen - seuraava »

poda19

I'm losing my mind this time,
i have made changes to the database. created some tables and added a few columns to smf_members and smf_topics.
but every time i want to install a mod or add a custom action, the MODs isn't installed automatically so i have to install it manually. but when i run the installation script the only thing i get is this mesasge:
'no database selected'
this is the query that is causing this error:
$request = $smcFunc['db_query']('', '
SELECT mem.*, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type,
                grades.id gradeid
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = {int:id_member})
                    INNER JOIN classes ON mem.classid=classes.id
                    INNER JOIN grades ON grades.id=classes.gradeid
WHERE mem.id_member = {int:id_member}
LIMIT 1',
array(
'id_member' => $id_member,
)
);

every time i have to install a new smf to get the installers to work. then i install the MOD, then see what tables are changed/created then go to my forum's DB and do all the things manually.
i can't go on this way. can anyone help please? am i doing something wrong? is there anything i should do when i change database tables?
I think people are stupid enough to lie

IchBin™

Hard to tell what you are doing. How are you running the installer when you get the DB error? Do you have other queries in the same file that are running fine?
IchBin™        TinyPortal

poda19

Thanks for your response IchBin.
i'm just joining my tables to select some data and add it to $user_settings.
the code is in Load.php, loadUserSettings();
and about the problem,
i edited the subs-DB-mysql.php and selected the database myself:
(i added this before line 350)

$connection=mysql_connect('localhost','user','pass');
if(!mysql_select_db('smf',$connection))
    die('error again');


then everything went ok and my mod was installed successfully.
the database was ACTUALLY not selected.
is it possible that this is a bug?
I think people are stupid enough to lie

Arantor

No, but what you've done now might well be a bug.

When running in SSI mode, the system very very deliberately DOES NOT select the database. Instead, $db_prefix is adjusted to include the database name so that other stuff running in the same page is not affected by the change of database.
Holder of controversial views, all of which my own.


poda19

Lainaaso that other stuff running in the same page is not affected by the change of database.
i don't get the point. can you please explain more?
and why should my JOINs cause a database error so?
I think people are stupid enough to lie

Arantor

Lainaai don't get the point. can you please explain more?

SSI is designed to be used in the same page as other stuff. Consider the case where you'd use SSI in, say, the layout of a WordPress blog. If SSI were to just change the database like that, it would break WordPress, so SSI deliberately does not change the database.

How, exactly, are you trying to do this manual installation? Where exactly is that query running?
Holder of controversial views, all of which my own.


poda19

the query that i mentioned in my first post is in Load.php, in loadUserSettings() function. but problem is not with this single query.
when i remove the changes i have made to this query, another query that i have placed in the end of loadUserSettings() generates the error:
if($user_info['id']!=0)
    {
    $date=date('Y-m-d',time());
    $result=$smcFunc['db_query']('','SELECT DISTINCT type,solutionid FROM students_downloads
                                 WHERE rated=0 AND studentid={int:studentid} AND date<{string:date}',
                                 array('studentid'=>$user_info['id'],'date'=>$date)
                                 );
    $row=$smcFunc['db_num_rows']($result);
    if($row>0)
        $user_info['unrated_downloads']=$row;

    }

if i remove these two modifications, the install script runs without error.

Lainaa
How, exactly, are you trying to do this manual installation?
i do the changes in the files and copy the neccesary files then run the install script (all as instructed in MOD's download page).
by the way i'm installing 'Adk Blog' mod.
i have the same problem when i want to add custom actions (with integration hooks) too.
I think people are stupid enough to lie

Arantor

I see your problem. students_downloads doesn't have a db_prefix on it, which means what is normally done won't get done. It is the {db_prefix} that resolves the lack of database being selected.

grades, much the same. Since these tables do not have the SMF prefix on them, instead you will need to manually add the database name. If the database is called 'mydb' for the sake of argument, you will need to change things like grades.id to mydb.grades.id (and yes, this does work just fine)
Holder of controversial views, all of which my own.


poda19

you are an angel arnator!
it's now making sense for me. SSI doesn't select db but edits db_prefix. my queries don't have one. so things get messed up.

edit*:everything works fine now. thanks again Arnator
I think people are stupid enough to lie

mosravo

Lainaus käyttäjältä: Arantor - lokakuu 18, 2012, 12:03:00 IP
I see your problem. students_downloads doesn't have a db_prefix on it, which means what is normally done won't get done. It is the {db_prefix} that resolves the lack of database being selected.

grades, much the same. Since these tables do not have the SMF prefix on them, instead you will need to manually add the database name. If the database is called 'mydb' for the sake of argument, you will need to change things like grades.id to mydb.grades.id (and yes, this does work just fine)

thanks Arantor, you really made me to scale through a problem. i am greatfull it works find

I actually added some tables to smf forum and relate them to the smf_member table and i was have this issue no database select but with your solution everything is working fine now. thanks.

Cheers

Advertisement: