Page 1 of 1
mysql_select_db() in UDT breaks the page
Posted: Tue Jan 20, 2009 8:59 am
by crankshaft
I have a UDT where I need to pull data from another database, which works fine if I use it in the body.
But when I try and use it in the header, it kills the page with the following error:
"Warning: Invalid argument supplied for foreach() in /Volumes/DATA/Html/cms/lib/content.functions.php on line 234"
This happens if the tag is placed anywhere higher than the Breadcrumbs Tag.
How do I overcome this ??
Re: mysql_select_db() in UDT breaks the page
Posted: Tue Jan 20, 2009 12:33 pm
by viebig
Well
It seens like a common PHP error, probably related with the foreach parameter that should be an array.
You must supply at least a part of the UDT code so we can understand what´s happening.
Anyway it´s really strabge since the value is being tested in content.functions.php on 1.5.2
Please provide more information, PHP, CMSMS version, and a piece of the udt
Regards
G
Re: mysql_select_db() in UDT breaks the page
Posted: Tue Jan 20, 2009 1:04 pm
by crankshaft
Hello G;
Thanks so much, actually just adding the following UDT anywhere above the breadcrumbs in the template kills the page:
Code: Select all
## UDT db_test ###
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("yrdbname") or die(mysql_error());
I have commented out line by line and tested which line is the killer and it's:
Code: Select all
mysql_select_db("yrdbname") or die(mysql_error());
I am guessing that this is over-writing the cms database select ?!
P
Re: mysql_select_db() in UDT breaks the page
Posted: Wed Jan 21, 2009 1:35 am
by Nullig
At the end of your UDT have you closed your MySql connection and reopened the CMSMS connection?
mysql_close ($my_dbconn); <- use whatever your connection is called
adodb_connect();
Nullig
Re: mysql_select_db() in UDT breaks the page
Posted: Wed Jan 21, 2009 8:46 am
by crankshaft
Hi;
Yes, I closed the connection and also freed up the memory:
mysql_close();
mysql_free_result()
But anyway, I have given up and decided to add a table to the existing database instead, so it's not really solved !
P
Re: mysql_select_db() in UDT breaks the page
Posted: Wed Jan 21, 2009 9:18 am
by irish
crankshaft,
Take a look at this topic, it might help you out:
http://forum.cmsmadesimple.org/index.ph ... #msg114472
Re: mysql_select_db() in UDT breaks the page
Posted: Wed Jan 21, 2009 5:18 pm
by Nullig
Did you add the:
adodb_connect();
to reopen the CMSMS db connection?
Nullig