I am getting crazy error messages after using custom user tags. The messages appear to be within the menu area, that is in place where the menu should be. The menu does not display at all and everything else after on that page gets cut off. Here are the error messages:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'username'@'localhost' (using password: NO) in /home/username/public_html/lib/adodb_lite/adodbSQL_drivers/mysql/mysql_driver.inc on line 174
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/username/public_html/lib/adodb_lite/adodbSQL_drivers/mysql/mysql_driver.inc on line 174
Fatal error: Call to a member function on a non-object in /home/username/public_html/modules/MenuManager/action.default.php on line 90
Error messages after using custom tags
Re: Error messages after using custom tags
Is your custom tag creating/using a mysql connection?
It looks like CMS Made Simple lost connection.
When you need database access from your tag, it's best to use the existing ADOdb object:
When using a MySQL connection, make sure you close the connection by passing the resource ID returned by mysql_connect() to mysql_close():
A work around is to re-connect CMS Made Simple at the end of your (tag) code:
Regards,
D
It looks like CMS Made Simple lost connection.
When you need database access from your tag, it's best to use the existing ADOdb object:
Code: Select all
$db =& $gCms->GetDb();
Code: Select all
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password');
- - database code - -
mysql_close($link);
Code: Select all
adodb_connect();
D
Re: Error messages after using custom tags
Yes, the tag does open a new MySQL connection. The things is I can't reuse the CMSMS's connection, because I am connecting to a different database. I will try you suggestion about closing the connection though. I think I understand what is going on. When I don't specify which connection to close, it just closes the connection that belongs to CMSMS.
Re: Error messages after using custom tags
Nice one Dee! Thanks! The workaround seemed to work.
I just thought of something. The second database I am connecting to through the tag uses the same username and password as the CMSMS uses. Is there a way to reuse the connection, but select a different database?
I just thought of something. The second database I am connecting to through the tag uses the same username and password as the CMSMS uses. Is there a way to reuse the connection, but select a different database?
Re: Error messages after using custom tags
It's possible to use the same connection by changing database:
You can also create a second connection:
Regards,
D
Code: Select all
global $gCms;
$conn =& $gCms->GetDb();
$conn->Execute('USE your_db');
... your (ADOdb) database code ...
$conn->Execute('USE cms');
Code: Select all
global $gCms;
$config =& $gCms->GetConfig();
$conn =& ADONewConnection('mysql');
$conn->PConnect($config['db_hostname'], $config['db_username'], $config['db_password'], 'your_db');
... your (ADOdb) database code ...
$conn->Close();
D
Re: Error messages after using custom tags
Great! Thank you very much for your in-depth replies. This is very helpfull!