Page 1 of 1

after "mysql_select_db" (User Defined Tag) -> "unable to read resource"

Posted: Fri Aug 24, 2007 3:52 am
by phil_nyc
Hi guys,

I have a problem with including php code via an user defined tag.

I created a tag that includes mysql connection code.

If I use the user defined tag, the other resources like a global_content tag can not be load correctly.
"Smarty error: unable to read resource: "globalcontent..."

The problem is the php function mysql_select_db I think. Just a normal echo command (for example) works fine.
There must be a problem with this mysql function.

Anybody with same experiences or solutions?

Thanks,
Phil

Re: after "mysql_select_db" (User Defined Tag) -> "unable to read resource"

Posted: Fri Aug 24, 2007 4:05 am
by calguy1000
This has been answered many times before and it's searchable in the forums.  but I'll answer some of it anyays (it's your first post).

1) Certain variables are used by CMS made simple, and could cause problems (depending on scope) if an external php script uses the same variable names.  One of those could be $db.  We make every effort to make this stuff scope safe, and to have as few as possible globals, but.... errors could prop in (you din't reveal anything about which version of CMS you were using, the type of host you were on....)

2) if you look in the php manual for the mysql_connect_db() function, it will tell you that it:
Sets the current active database on the server that's associated with the specified link identifier. Every subsequent call to mysql_query() will be made on the active database.
Therefore, unless something is done, every subsequent call to mysql may be using the wrong database, and cause a whole world of problems.

There are solutions to this..... searching in this forum will find them for you.