Forum Moderators: coopster

Message Too Old, No Replies

Why is one php 'include' snippet killing the others?

         

flamesrock

11:37 pm on Aug 30, 2004 (gmt 0)

10+ Year Member



Hi,

I run a site based loosely around mamboserver, and simplemachines forums. Simplemachines contains an SSI.php file with various functions- the one I want being a login box that I can put on the main mamboserver page along with the other php functions.

So basically, I go: <?php include ("bboard/SSI.php");?><?php ssi_login();?> right underneath the main menu, which causes the other functions to mess up:

Warning: Invalid argument supplied for foreach() in /home/simcitys/public_html/new_simcitysphere/classes/mambo.php on line 1640
Table \'simcitys_scsbboard.mos_content\' doesn\'t exist SQL=SELECT ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count,\na.*, u.name AS author, u.usertype\nFROM mos_content AS a\nINNER JOIN mos_content_frontpage AS f ON f.content_id = a.id\nLEFT JOIN mos_users AS u ON u.id = a.created_by\nLEFT JOIN mos_content_rating AS v ON a.id = v.content_id\nWHERE a.state=\'1\'\n AND (publish_up = \'0000-00-00 00:00:00\' OR publish_up <= NOW())\n AND (publish_down = \'0000-00-00 00:00:00\' OR publish_down >= NOW())\nORDER BY f.ordering, a.ordering ASC, a.catid, a.sectionid LIMIT 6

No items to display

When I remove <?php include ("bboard/SSI.php");?>, everything EXCEPT for the login box works :(

How can I possibly fix this without destroying one or the other?

-thanks

httpwebwitch

2:26 pm on Aug 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



seems like you have variable collisions.
SSI.php is overwriting a variable that is used elsewhere in the script.

This error message:
Invalid argument supplied for foreach()

tells me that PHP is expecting to get an array on line 1640, but it's getting something else instead. Check that line, look at the arguments in the foreach loop, and see if any of those variables are being redefined within SSI.php.

It could be a quick painless 2-second fix, or a week of headaches and debugging. good luck.

flamesrock

9:35 pm on Aug 31, 2004 (gmt 0)

10+ Year Member



Yup, they're being redefined to look in the bboard database, instead of the mamboserver database.

(simcitys_scsbboard.mos_content)

Is there anyway I can tell it to go back to the mamboserver db?

ergophobe

8:10 pm on Sep 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you just do a universal search and replace in one of the scripts (e.g. mambo) and rename the variable in question so that it does not get redefined later in the SSI?

Based on the error output, I'm guessing the problem happens fairly far upstream with a failed query? Is the array in the foreach on line 1640 based on the results returned from a query?