1
ViperSBT
Custom Blocks weird behavior
  • 2005/12/20 0:57

  • ViperSBT

  • Just popping in

  • Posts: 88

  • Since: 2004/9/27


OK, after migrating my site to a new environment I am now experiencing something really weird with any of my custom blocks that are .php files using an include function. Here is a snippet of one of the files (they all start out this way):
Quote:
require('config.php');

// Connects to the database
$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die(mysql_error());
mysql_select_db(SQL_DB,$conn);


The problem seems to be with the
Quote:
mysql_select_db(SQL_DB,$conn);
with it there (which it has to be) I get a blank page. If I comment that single line out, XOOPS works normally, but I am not connecting to my DB to pull any data... There are no errors being shown, if I turn on debugging I don't get anything besides the normal Notices.

I am using XOOPS 2.2.3 Final. The block is set to PHP Script and has a single line of:
Quote:
include XOOPS_ROOT_PATH.'/blockname.php';
and the template is:
Quote:
<{$block.content}>
Brett M. Williams
Co-Founder, The United Flyball League International
http://www.u-fli.com

2
davidthomas1
Re: Custom Blocks weird behavior

I assume you defined your SQL connection constants.

e.g define ("SQL_USER", "USER1");

Otherwise you'll need "$" symbols in front of those variable names.

Another thing, try changing this line from

mysql_select_db(SQL_DB,$conn);
to
mysql_select_db
(SQL_DB);


finally, try specifying the absolute path for:

require('config.php');
e.g
require('home/username/public_html/xoops/config.php');


HIH
みんなちがってみんないい。

XOOPS 2.0.13.2

3
ViperSBT
Re: Custom Blocks weird behavior
  • 2005/12/20 16:19

  • ViperSBT

  • Just popping in

  • Posts: 88

  • Since: 2004/9/27


Yes, the constants are being controlled from the config.php file.

Changing the DB select to
Quote:
mysql_select_db(SQL_DB);

creates the same problem.

I did not mention in my original post that there is one error that I am getting that changes based upon the module I have assigned to the start page. Currently I have News assigned as that module and am getting the following error:
Quote:

Fatal error: Call to a member function on a non-object in /home/httpd/vhosts/ufli/include/notification_functions.php on line 95


Now this module works fine on its own, it works fine as the start page module when my custom blocks are not set to visible, and it worked fine on the old server with the custom blocks, so I am pretty sure it isn't the modules fault.

The blocks work fine on their own, and they work find on the start page if I have no modules set for the front page. It is only when combining modules with these blocks that I am getting a problem.

Specifying the absolute path made no difference either. I have checked to verify that all the constants are being loaded and they are.
Brett M. Williams
Co-Founder, The United Flyball League International
http://www.u-fli.com

4
ViperSBT
Re: Custom Blocks weird behavior
  • 2005/12/20 16:48

  • ViperSBT

  • Just popping in

  • Posts: 88

  • Since: 2004/9/27


OK, I figured out the problem and am documenting it here in the hopes that it may help others out in the future. When I moved to my new server I thought I would make things cleaner by simply having a single user that would have access to my XOOPS DB and my statistics DB. On my old server these were two seperate users.

So I created a new user for the statistics DB, updated my config.php to reflect the new user and password. Everything is working fine! No changes to any of my PHP code were needed.

So why was this a problem? My best guess has to do with when you create a new DB select it maintains that select for all future queries and there must be a query after the blocks that was not able to execute properly since I had a new DB selection. If anyone can better explain this, I would love to understand it better.
Brett M. Williams
Co-Founder, The United Flyball League International
http://www.u-fli.com

Login

Who's Online

376 user(s) are online (338 user(s) are browsing Support Forums)


Members: 0


Guests: 376


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits