Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Aug 2002
Posts: 23
Newbie
Newbie
Joined: Aug 2002
Posts: 23
How do I open a connection to another MYSQL DB - not on the server UBBT is running on , query it and display the results in my custom pal box.

I have no problem querying the DB that's running UBBT and displaying those results

BUT

When I try - within the pal box - to open a connection to another MYSQLDB on another machine using mysql_connect("ip addy of other machine", "username", "password") or die ;
I die

Any ideas?

Thanks

Sponsored Links
Joined: Jun 2001
Posts: 3,273
That 70's Guy
That 70's Guy
Offline
Joined: Jun 2001
Posts: 3,273
I have never tried this myself so I couldn't even offer a guess.

Anyone else tried this?

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
OK - this code is probably sloppy to the real MySQL gurus here... but I added a hack to the shortstatspal to pull the total number of photos from my photopost database.

It was a heck of a run... kept getting non-member function errors and such. But by luck and the grace of god, I somehow got it working.

Here's what I did:

// Hack to include Photo Stats
$photolink = mysql_connect("DBSERVERNAME", "PHOTODBUSER", "PHOTODBPASS") or die ('I cannot open the Photo DB');
mysql_select_db ("PHOTODBNAME",$photolink)or die("Could not connect to the Photo DB");
$query = "SELECT SUM(views), SUM(filesize), COUNT(*) AS fsize FROM photos";
$totalv = $dbh -> do_query($query,$photolink);
list( $totalviews, $diskuse, $totalphotos ) = $dbh -> fetch_array($totalv);
mysql_close($photolink);

$relink = mysql_connect("DBSERVERNAME", "THREADSDBUSER", "THREADSDBPASS") or die ('I cannot open the server');
mysql_select_db("THREADSDB",$relink)or die("I cannot reconnect");


-------------end

This is the part that's probably not cool... but I just hardcoded in the database names, users names and passwords for:
DBSERVERNAME
PHOTODBUSER
PHOTODBPASS
PHOTODBNAME
THREADSDBUSER
THREADSDBPASS
THREADSDB

So be sure and substitute the real values for above.

Hope it helps a bit.

Maybe one of the Dave's will see a way to clean it up. OR - surprise me... maybe I did it right!

Joined: Aug 2002
Posts: 23
Newbie
Newbie
Joined: Aug 2002
Posts: 23
thanks Josh - I'll give it a shot and let you know what happens!

Joined: Aug 2002
Posts: 23
Newbie
Newbie
Joined: Aug 2002
Posts: 23
Got it!

Glen Lachart

There's a splash screen then the IIP. The custom pal box - High Scores in the top right col - opens a DB on another server (in another country) grabs the scores then goes back to local host and displays the rest of the Pal boxes below it.

I'm actually running two servers. One in the UK (which has the UBB on it) and another in Curacao -MYSQL - replicates the UK ubbt and other stuff to the Server in CUR. The Shockwave Game is also integrated into the UBB using the UBBT login and cookie so that users don't have to register once for the UBB and another time for the Shockwave game.

Still a lot of cleaning up to do in Glen Lachart - but it's coming right along!

Thanks again


Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)