Page 1 of 1

[SOLVED] Connect to another DB within Module

Posted: Tue Feb 26, 2008 2:03 pm
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

Re: Connect to another DB within Module

Posted: Tue Feb 26, 2008 3:45 pm
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

Re: Connect to another DB within Module

Posted: Tue Feb 26, 2008 3:54 pm
by jensr
Thanks a lot.

That solved my problem!

Re: Connect to another DB within Module

Posted: Tue Feb 26, 2008 3:56 pm
by Nullig
Remember to add [solved] to the title of your original post.

Nullig