Jump to content


Photo

including my php file breaks the db connection of parent script


  • Please log in to reply
2 replies to this topic

#1 schwim

schwim
  • Members
  • PipPip
  • Member
  • 12 posts
  • LocationWestern NC, US

Posted 01 October 2006 - 02:12 AM

Hi there guys,

I originally asked this on another forum, but I've either worn out my welcome, or I've stumped them all.

I created a script that uses a mysql connection, and it's intended to be inserted as a block in other scripts.  I'm attempting to insert it into a forum system, but it's breaking the mysql connection of the forum script when I try to use it. The db connection is made in a config file, and it's called by the block script.

forum db is roughing_forum
my script is roughing_automonial
db client is the same for both

The connection string for my script(config.php):

 $autoconn = mysql_connect("$dhost","$dusername","$dpwd") or die ("Unable to connect to database.");

$dbi=mysql_select_db($dbname,$autoconn) or die("Unable to make master connection to database from the config file!" . mysql_error()); 

When I insert the script into the forum via include, I get an error that shows me that the forum is now trying to use my script's db for data:

Fatal error: Database error: 1146: Table 'roughing_automonial.v_pm' doesn't exist - File: /home/roughing/public_html/templates/1/header.html(54) : eval()'d code on line 26 in /home/roughing/public_html/classes/database/mysql.inc.php on line 291


So I added the following to the very last line of my block script:

mysql_close($autoconn);

With this setup, the error I receive makes it look like my script has now shut down all mysql connections:

Fatal error: Database error: : - File: /home/roughing/public_html/templates/1/header.html(54) : eval()'d code on line 26 in /home/roughing/public_html/classes/database/mysql.inc.php on line 291


I don't know what else to do.  I tried

$autoconn = null;

but that put me back to the first error.

Any help in solving this would be greatly appreciated.

thanks,
json

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 01 October 2006 - 05:08 AM

You will either need to go through all the scripts in the forum and explicitly tell each database call to use a particular link (the forums conection), or, as a quick workaround, do as you have done and close your connection, but afterwoods re open the forums connection explicitly.

Understand?

#3 schwim

schwim
  • Members
  • PipPip
  • Member
  • 12 posts
  • LocationWestern NC, US

Posted 02 October 2006 - 01:28 AM

Hi thorpe and thanks very much for the reply.

I think I understand what you are saying, but this won't work for my needs.

I am writing the script to be an automated testimonial block that people can install on their sites, and their needs will all differ.  Some may be integrating it into a home-brew site, some phpBB, etc.

Is there no way to integrate an out of the box script install into an existing site?  I would be quite surprised to find that was the case.

Thanks very much for your time,
json




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users