| Author |
Message |
Henrick
Private


Joined: Jun 02, 2003
Posts: 35
|
Posted:
Fri Jul 04, 2003 12:31 pm |
  |
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. |
|
|
   |
 |
Raven
General


Joined: Mar 22, 2003
Posts: 5233
Location: USA
|
Posted:
Fri Jul 04, 2003 12:47 pm |
  |
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 |
|
    |
 |
Henrick
Private


Joined: Jun 02, 2003
Posts: 35
|
Posted:
Fri Jul 04, 2003 12:55 pm |
  |
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. The block does pull the data and display it fine, which is the odd part. |
|
|
   |
 |
Raven
General


Joined: Mar 22, 2003
Posts: 5233
Location: USA
|
Posted:
Fri Jul 04, 2003 12:57 pm |
  |
|
    |
 |
Henrick
Private


Joined: Jun 02, 2003
Posts: 35
|
Posted:
Fri Jul 04, 2003 1:04 pm |
  |
I do have AIM. PM'ing you the name. |
|
|
   |
 |
chris-au
Elite Nuker


Joined: Jan 31, 2003
Posts: 717
|
Posted:
Fri Jul 04, 2003 7:50 pm |
  |
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
|
|
    |
 |
Raven
General


Joined: Mar 22, 2003
Posts: 5233
Location: USA
|
Posted:
Fri Jul 04, 2003 7:52 pm |
  |
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 |
|
    |
 |
Henrick
Private


Joined: Jun 02, 2003
Posts: 35
|
Posted:
Fri Jul 04, 2003 8:49 pm |
  |
Thanks Chris... adding the reconnection at the bottom worked like a champ.
and no problem.. Im going to go and enjoy the fireworks myself.
Thanks again for the assistance. |
|
|
   |
 |
chris-au
Elite Nuker


Joined: Jan 31, 2003
Posts: 717
|
Posted:
Fri Jul 04, 2003 10:23 pm |
  |
OK, nothing nicer than some good fireworks!
<img src="http://www.sengers-au.com/images/firework.jpg" alt="firework"> |
_________________ Chris
|
|
    |
 |
Raven
General


Joined: Mar 22, 2003
Posts: 5233
Location: USA
|
Posted:
Mon Jul 07, 2003 6:18 pm |
  |
| 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.
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
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 |
|
    |
 |
chris-au
Elite Nuker


Joined: Jan 31, 2003
Posts: 717
|
Posted:
Mon Jul 07, 2003 6:36 pm |
  |
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
|
|
    |
 |
Raven
General


Joined: Mar 22, 2003
Posts: 5233
Location: USA
|
Posted:
Mon Jul 07, 2003 6:38 pm |
  |
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 |
|
    |
 |
chris-au
Elite Nuker


Joined: Jan 31, 2003
Posts: 717
|
Posted:
Mon Jul 07, 2003 6:55 pm |
  |
Thanks for that, I might try your suggestion too. |
_________________ Chris
|
|
    |
 |
Raven
General


Joined: Mar 22, 2003
Posts: 5233
Location: USA
|
Posted:
Mon Jul 07, 2003 6:57 pm |
  |
|
    |
 |
chris-au
Elite Nuker


Joined: Jan 31, 2003
Posts: 717
|
Posted:
Mon Jul 07, 2003 7:41 pm |
  |
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
|
|
    |
 |
|
|