schwim Posted October 1, 2006 Share Posted October 1, 2006 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_forummy script is roughing_automonialdb client is the same for bothThe connection string for my script(config.php):[code=php:0] $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()); [/code]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:[quote]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[/quote]So I added the following to the very last line of my block script:[code=php:0]mysql_close($autoconn);[/code]With this setup, the error I receive makes it look like my script has now shut down all mysql connections:[quote]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[/quote]I don't know what else to do. I tried [code=php:0]$autoconn = null;[/code]but that put me back to the first error.Any help in solving this would be greatly appreciated.thanks,json Quote Link to comment https://forums.phpfreaks.com/topic/22631-including-my-php-file-breaks-the-db-connection-of-parent-script/ Share on other sites More sharing options...
trq Posted October 1, 2006 Share Posted October 1, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/22631-including-my-php-file-breaks-the-db-connection-of-parent-script/#findComment-101690 Share on other sites More sharing options...
schwim Posted October 2, 2006 Author Share Posted October 2, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22631-including-my-php-file-breaks-the-db-connection-of-parent-script/#findComment-102075 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.