mysql_select_db() in UDT breaks the page

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

mysql_select_db() in UDT breaks the page

Post 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 ??
viebig

Re: mysql_select_db() in UDT breaks the page

Post 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
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

Re: mysql_select_db() in UDT breaks the page

Post 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
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: mysql_select_db() in UDT breaks the page

Post 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
crankshaft
Forum Members
Forum Members
Posts: 57
Joined: Sun Mar 25, 2007 7:42 am

Re: mysql_select_db() in UDT breaks the page

Post 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
irish
Forum Members
Forum Members
Posts: 101
Joined: Tue Jun 03, 2008 2:31 pm

Re: mysql_select_db() in UDT breaks the page

Post by irish »

crankshaft,

Take a look at this topic, it might help you out:

http://forum.cmsmadesimple.org/index.ph ... #msg114472
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: mysql_select_db() in UDT breaks the page

Post by Nullig »

Did you add the:

adodb_connect();

to reopen the CMSMS db connection?

Nullig
Post Reply

Return to “Developers Discussion”