2 databases kills user defined tag/weird-interesting problem
-
aravenwood
2 databases kills user defined tag/weird-interesting problem
Hi I have a weird issue.
I have a CMS system setup. In addition, I have a second mysql database setup with some info I want to keep separate from the CMS database.
I have a page that displays data from the second database in a sortable grid.
On the page are a user defined tag and a global content block:
The global content bloc is for a footer at the bottom of every page, and that appears in my template
The user defined tag contains some php code that displays the grid/table. I noticed that whenever I make explicit mysql calls in this tag's php code, the footer disappears, and there is an CMS error in the source code.
global content bloc's error code:
string(61) "Smarty error: unable to read resource: "globalcontent:footer""
string(61) "Smarty error: unable to read resource: "globalcontent:footer""
global content bloc's code"
Grid tag's php:
//session junk here
session_start();
if(isset($_GET['direction'])){$direction=$_GET['direction'];}else{$direction='asc';}
if(isset($_GET['sort'])){$sort=$_GET['sort'];}else{$sort='lastname';}
if(isset($_SESSION['sort'])){
//read and write session logic here
}
echo'';
echo'';
echo '';
//header junk here from the database
echo'';
echo'';
echo'';
@MYSQL_CONNECT("server","user","password");
$sql='';
@mysql_select_db("selected_non_cms_database");
$sql="some sql here";
$result=MYSQL_QUERY($sql);
while ($row = mysql_fetch_assoc($result)) {
echo "";
//some junk here that I pull from the database
echo "";
}
mysql_free_result($result);
MYSQL_CLOSE();
Can anyone see where I have gone wrong? Why won't the footer show? I half suspect that my method of connecting to the mysql database is disabling the connection to the CMS connection to the CMS database, but I have no idea how to fix this if this is the case. At first I thought this was a session issue, but now I am not sure.
Any help would be appreciated.
Thanks,
Michael
I have a CMS system setup. In addition, I have a second mysql database setup with some info I want to keep separate from the CMS database.
I have a page that displays data from the second database in a sortable grid.
On the page are a user defined tag and a global content block:
The global content bloc is for a footer at the bottom of every page, and that appears in my template
The user defined tag contains some php code that displays the grid/table. I noticed that whenever I make explicit mysql calls in this tag's php code, the footer disappears, and there is an CMS error in the source code.
global content bloc's error code:
string(61) "Smarty error: unable to read resource: "globalcontent:footer""
string(61) "Smarty error: unable to read resource: "globalcontent:footer""
global content bloc's code"
Grid tag's php:
//session junk here
session_start();
if(isset($_GET['direction'])){$direction=$_GET['direction'];}else{$direction='asc';}
if(isset($_GET['sort'])){$sort=$_GET['sort'];}else{$sort='lastname';}
if(isset($_SESSION['sort'])){
//read and write session logic here
}
echo'';
echo'';
echo '';
//header junk here from the database
echo'';
echo'';
echo'';
@MYSQL_CONNECT("server","user","password");
$sql='';
@mysql_select_db("selected_non_cms_database");
$sql="some sql here";
$result=MYSQL_QUERY($sql);
while ($row = mysql_fetch_assoc($result)) {
echo "";
//some junk here that I pull from the database
echo "";
}
mysql_free_result($result);
MYSQL_CLOSE();
Can anyone see where I have gone wrong? Why won't the footer show? I half suspect that my method of connecting to the mysql database is disabling the connection to the CMS connection to the CMS database, but I have no idea how to fix this if this is the case. At first I thought this was a session issue, but now I am not sure.
Any help would be appreciated.
Thanks,
Michael
-
Sonya
Re: 2 databases kills user defined tag/weird-interesting problem
Hello,
I have exact the same problem. After closing connection to the other DB, I connect again to CMS DB:
It's only the global_content, which cannot be found anymore, ordinary templates can be processed. I was trying to find the difference in $this->smarty before and after connection to other DB. But there is a lot of stuff and I've gave up
Any idea from the developers? Just to point where to dig.
Thank you,
Sonya
I have exact the same problem. After closing connection to the other DB, I connect again to CMS DB:
Code: Select all
$dbinstance =& ADONewConnection($config['dbms'], 'pear:date:extend:transaction');
$conn_func = (isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true) ? 'PConnect' : 'Connect';
$connect_result = $dbinstance->$conn_func($config['db_hostname'], $config['db_username'], $config['db_password'], $config['db_name']);It's only the global_content, which cannot be found anymore, ordinary templates can be processed. I was trying to find the difference in $this->smarty before and after connection to other DB. But there is a lot of stuff and I've gave up
Any idea from the developers? Just to point where to dig.
Thank you,
Sonya
-
alby
Re: 2 databases kills user defined tag/weird-interesting problem
Try with:aravenwood wrote: ..............
@MYSQL_CONNECT("server","user","password");
$sql='';
@mysql_select_db("selected_non_cms_database");
$sql="some sql here";
$result=MYSQL_QUERY($sql);
while ($row = mysql_fetch_assoc($result)) {
echo "";
//some junk here that I pull from the database
echo "";
}
mysql_free_result($result);
MYSQL_CLOSE();
$new_link = @MYSQL_CONNECT("server","user","password", true);
$sql='';
@mysql_select_db("selected_non_cms_database", $new_link);
$sql="some sql here";
$result=MYSQL_QUERY($sql, $new_link);
from php.net:
Albyresource mysql_connect ( [string $server [, string $username [, string $password [, bool $new_link ...)
new_link
If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The new_link parameter modifies this behavior and makes mysql_connect() always open a new link, even if mysql_connect() was called before with the same parameters. In SQL safe mode, this parameter is ignored.
EDIT: MYSQL_CLOSE($new_link); also
Last edited by alby on Fri Jul 06, 2007 3:36 pm, edited 1 time in total.
-
Sonya
Re: 2 databases kills user defined tag/weird-interesting problem
Yes, but there are no issues with global_content. I am able to establish the connection twice and everything works in CMSMS as it should but no global content can be shown. Hmmm... Curious.cyberman wrote: I'm not a dev but have you read this?
-
Sonya
Re: 2 databases kills user defined tag/weird-interesting problem
Hello Alby,
I have different arguments. It's an other database, so new link has to be forced.alby wrote: new_link
If a second call is made to mysql_connect() with the same arguments,
Re: 2 databases kills user defined tag/weird-interesting problem
Try adding:
adodb_connect();
to the end of your UDT
Nullig
adodb_connect();
to the end of your UDT
Nullig
-
Sonya
Re: 2 databases kills user defined tag/weird-interesting problem
Hello,
thank you for your help. I was not able to solve this problem so far. But I used debug_backtrace() to find out where the problem lies. So I placed debug into /lib/adodb_lite/generic_modules/pear_module.inc in line 2 and got this before using the second database.
Then I compared the output after using second connection and there war a difference:
First argument is missing, so pear sucks.
There are some changes made with pear date according to config:
#Use ADODB Lite? This should be true in almost all cases. Note, slight
#tweaks might have to be made to date handling in a "regular" adodb
#install before it can be used.
I do not know if it depends on these changes.
Sonya
thank you for your help. I was not able to solve this problem so far. But I used debug_backtrace() to find out where the problem lies. So I placed debug into /lib/adodb_lite/generic_modules/pear_module.inc in line 2 and got this before using the second database.
Code: Select all
[1] => Array
(
[file] => xxxmyroot\lib\adodb.functions.php
[line] => 56
[function] => ADONewConnection
[args] => Array
(
[0] => mysql
[1] => pear:date:extend:transaction
)
)
Code: Select all
[1] => Array
(
[file] => xxxmyroot\lib\adodb.functions.php
[line] => 56
[function] => ADONewConnection
[args] => Array
(
[0] =>
[1] => pear:date:extend:transaction
)
)
There are some changes made with pear date according to config:
#Use ADODB Lite? This should be true in almost all cases. Note, slight
#tweaks might have to be made to date handling in a "regular" adodb
#install before it can be used.
I do not know if it depends on these changes.
Sonya
Last edited by Sonya on Fri Jul 20, 2007 4:26 pm, edited 1 time in total.
Re: 2 databases kills user defined tag/weird-interesting problem
Nullig wrote: Try adding:
adodb_connect();
to the end of your UDT
Nullig
\o/ sorry to interrupt, but i googled and got lucky because your tip works swell for me.. thanks.
-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: 2 databases kills user defined tag/weird-interesting problem
Another FAQ issue.... though an advanced topic.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.

