[SOLVED] Connect to another DB within Module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
jensr
New Member
New Member
Posts: 8
Joined: Tue Feb 26, 2008 1:59 pm

[SOLVED] Connect to another DB within Module

Post by jensr »

Hey,

I tried to include a php script as module into cmsmadesimple.
Everything works fine, but I get following warnings at the end of the page:

Code: Select all

Warning: mysql_real_escape_string(): 25 is not a valid MySQL-Link resource in E:\htdocs\cmsmadesimple\lib\adodb_lite\adodbSQL_drivers\mysql\mysql_driver.inc on line 197
string(61) "Smarty error: unable to read resource: "globalcontent:footer""
Warning: mysql_real_escape_string(): 25 is not a valid MySQL-Link resource in E:\htdocs\cmsmadesimple\lib\adodb_lite\adodbSQL_drivers\mysql\mysql_driver.inc on line 197

Warning: mysql_real_escape_string(): 25 is not a valid MySQL-Link resource in E:\htdocs\cmsmadesimple\lib\adodb_lite\adodbSQL_drivers\mysql\mysql_driver.inc on line 197
string(61) "Smarty error: unable to read resource: "globalcontent:footer""
I think thats because I connect to another database within the included script.
I tried to put following code at the end of the DoAction()-Function, but this doesn't solve the problem:

Code: Select all

//$cmsdb =& $this->GetDB();
Perhaps somebody can help me?

Kind Regards,
Jens
Last edited by jensr on Tue Feb 26, 2008 4:01 pm, edited 1 time in total.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: Connect to another DB within Module

Post by Nullig »

If you're not planning to create tables within CMSms and wish to maintain a separate db/tables, at the end of your script, make sure you close the connection to your external db and reopen the connection to CMSms db by adding the following lines:.

mysql_close ($my_dbconn); <-- whatever your connection is called

adodb_connect();

Nullig
Last edited by Nullig on Tue Feb 26, 2008 3:47 pm, edited 1 time in total.
jensr
New Member
New Member
Posts: 8
Joined: Tue Feb 26, 2008 1:59 pm

Re: Connect to another DB within Module

Post by jensr »

Thanks a lot.

That solved my problem!
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: Connect to another DB within Module

Post by Nullig »

Remember to add [solved] to the title of your original post.

Nullig
Post Reply

Return to “Modules/Add-Ons”