You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 53 guest(s) and 2 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Question regarding block and another MySQL database [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Henrick
Private
Private


Joined: Jun 02, 2003
Posts: 35


PostPosted: Fri Jul 04, 2003 12:31 pm Reply with quoteBack to top

Hi.. Im wondering if anyone has any ideas on what might be causing this issue or where I can look to resolve.

I have created a block on my site that pulls data from a seperate MySQL database than that of my php nuke 6.7 website. The problem is after adding this block, it seems to be that I lose connection to my nuke database. Its kinda hard to explain, but one thing I notice is right after I add the block, the block add/admin page refreshes and it shows no blocks in the list or if I go to the index page I have no center or left side content.. only the right side blocks are shown.

I have tried almost everything to try and narrow this down, but it all points back to when I make the call to the seperate database, get the data, use $content to display it my problems start happening. I can post the block code if helpful, I just want to make sure its nothing that Im missing. I have made sure Im using different variables for connecting to the database, and for the array Im creating with the data.

Thanks.
Find all posts by HenrickView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Fri Jul 04, 2003 12:47 pm Reply with quoteBack to top

If it's not too long, post the code. I want to understand exactly the structure of what you're attempting. It should, in theory, works as long you have kept the connection strings separate.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
Henrick
Private
Private


Joined: Jun 02, 2003
Posts: 35


PostPosted: Fri Jul 04, 2003 12:55 pm Reply with quoteBack to top

No problem. Its fairly small.
Code:

<?php
if (eregi("block-Last_5_Submits.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

$dbcon = sql_connect("localhost", "$username", "$password", "$dbasename");
$tresult = mysql_query("SELECT name, level, timestamp2 FROM $tablename ORDER BY timestamp2 DESC Limit 5",$dbcon);
$trow = sql_fetch_array($tresult);
$content = "<tr><td>Name</td><td align=\"center\">Level</td></tr>";
do {
$name = $trow["name"];
$level = $trow["level"];
$timestamp2 = $trow["timestamp2"];
$content .= "<tr><td><a href=\"acstats/view.php?name=$name\">$name</a></td><td align=\"center\">$level</td></tr>";
} while ($trow = sql_fetch_array($tresult));
mysql_close($dbcon);
?>

I have only one line I left out. Im using an include for connection variables. I have tried using straight username, password, etc.. with the same result. Im also sure there is a better way to do this, I figure I can streamline once I cross this bridge. Smile The block does pull the data and display it fine, which is the odd part.
Find all posts by HenrickView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Fri Jul 04, 2003 12:57 pm Reply with quoteBack to top

Have you got YIM or Aim or ICQ?

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
Henrick
Private
Private


Joined: Jun 02, 2003
Posts: 35


PostPosted: Fri Jul 04, 2003 1:04 pm Reply with quoteBack to top

I do have AIM. PM'ing you the name.
Find all posts by HenrickView user's profileSend private message
chris-au
Elite Nuker
Elite Nuker


Joined: Jan 31, 2003
Posts: 717


PostPosted: Fri Jul 04, 2003 7:50 pm Reply with quoteBack to top

This is how I do it in a number of script (I use 4 databases at my site)

Code:

//TO START YOUR OTHER DATABASE CONNECTION PUT AT THE START OF YOUR SCRIPT:

include("config2.php"); //<---------DETAILS OF SECOND DATABASE HERE LIKE CONIG.PHP
mysql_connect("$dbhost", "$dbuname", "$dbpass");
mysql_select_db($dbname) or HEADER("Location: no_data.html");


//THE REST OF YOUR SCRIPT

//AND AT THE BOTTOM SOMEWHERE, YOU MIGHT HAVE TO DO THAT AT A FEW PLACES MAYBE IN YOUR SCRIPT PUT:

include("config.php");  //<---THIS WILL RECONNECT TO YOUR 'NORMAL' DB
mysql_connect("$dbhost", "$dbuname", "$dbpass");
mysql_select_db($dbname) or die ("Unable to select database");

_________________
Chris
Find all posts by chris-auView user's profileSend private messageVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Fri Jul 04, 2003 7:52 pm Reply with quoteBack to top

It should work as Chris points out. Sorry I haven't gotten back with you - went to see the fireworks! Let us know if you figure it out or still need help.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
Henrick
Private
Private


Joined: Jun 02, 2003
Posts: 35


PostPosted: Fri Jul 04, 2003 8:49 pm Reply with quoteBack to top

Thanks Chris... adding the reconnection at the bottom worked like a champ.

and no problem.. Im going to go and enjoy the fireworks myself. Smile

Thanks again for the assistance.
Find all posts by HenrickView user's profileSend private message
chris-au
Elite Nuker
Elite Nuker


Joined: Jan 31, 2003
Posts: 717


PostPosted: Fri Jul 04, 2003 10:23 pm Reply with quoteBack to top

OK, nothing nicer than some good fireworks!
<img src="http://www.sengers-au.com/images/firework.jpg" alt="firework">

_________________
Chris
Find all posts by chris-auView user's profileSend private messageVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jul 07, 2003 6:18 pm Reply with quoteBack to top

Henrick wrote:
Thanks Chris... adding the reconnection at the bottom worked like a champ.

and no problem.. Im going to go and enjoy the fireworks myself. Smile

Thanks again for the assistance.

I got to thinking about this and I believe that the reconnect is not needed (although it does not hurt anything, just extra overhead) if you pass the connection string instead. I'd be curious if you could try it. This would be the general setup
Code:
include("config1.php");
//<---------DETAILS OF FIRST DATABASE HERE LIKE CONIG1.PHP
$firstConn = mysql_connect("$dbhost", "$dbuname", "$dbpass");
mysql_select_db($dbname,$firstConn) or die("Can't connect");

include("config2.php");
//<---------DETAILS OF SECOND DATABASE HERE LIKE CONIG2.PHP
$secondConn = mysql_connect("$dbhost", "$dbuname", "$dbpass");
mysql_select_db($dbname,$secondConn) or die("Can't connect");
Now, you just use the 2 different connection strings (or as many as you need/want) to designate which database you are referring to Wink

This is the way MySQL connection functions and access functions are designed to be used, i.e., the second parameter is the connection parameter.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
chris-au
Elite Nuker
Elite Nuker


Joined: Jan 31, 2003
Posts: 717


PostPosted: Mon Jul 07, 2003 6:36 pm Reply with quoteBack to top

Never too old yo learn.

Quote:

Now, you just use the 2 different connection strings (or as many as you need/want) to designate which database you are referring to


But, did you test this out?

_________________
Chris
Find all posts by chris-auView user's profileSend private messageVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jul 07, 2003 6:38 pm Reply with quoteBack to top

Actually, yes. But I wanted Henrick to test his too. I actually use this elsewhere but just didn't have my hands on it at the time.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
chris-au
Elite Nuker
Elite Nuker


Joined: Jan 31, 2003
Posts: 717


PostPosted: Mon Jul 07, 2003 6:55 pm Reply with quoteBack to top

Thanks for that, I might try your suggestion too.

_________________
Chris
Find all posts by chris-auView user's profileSend private messageVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jul 07, 2003 6:57 pm Reply with quoteBack to top

Chris,

Have you got a website? I'd like to see what you've done.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
chris-au
Elite Nuker
Elite Nuker


Joined: Jan 31, 2003
Posts: 717


PostPosted: Mon Jul 07, 2003 7:41 pm Reply with quoteBack to top

pm forwarded.

To see a few things, try also to ckick on My Menu / Family Tree / Enter Family Tree or Information / Statistics to see the change of sideblocks and theme and logo.

_________________
Chris
Find all posts by chris-auView user's profileSend private messageVisit poster's website
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.241 Seconds - 355 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::