Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.3
Author Message
Rage
Insane



Joined: Jul 30, 2004
Posts: 85

PostPosted: Sat Sep 18, 2004 4:28 am Reply with quote

Hi all, I'm having alot of trouble with trying to make two 7.3s use the same nuke_users table.

Here is the set of code that I've been trying to accomplish this from:

Code:
$result = $db->sql_query("SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'");

   $row = $db->sql_fetchrow($result);



$result = $db->sql_query("SELECT user_password FROM ".$dbname_2.".".$user_prefix."_users WHERE user_id='$uid'", ".$dbconnection_2.");


$result2 = $db->sql_query("SELECT points FROM ".$dbname_2.".".$user_prefix."_users WHERE user_id='uid'", $dbconnection_2);

   $row = $db->sql_fetchrow($result);


But it does't seem to work, and I'm not 100% sure what to define in config.php (such as the second db fields etc)

Anyone have any ideas? Or new code? Smile

Help is greatly appreciated.

_________________
It's not that I'm afraid of dying, it's just that I don't want to be there when it happens. - Woody Allen 
View user's profile Send private message
MrFluffy
Hangin' Around



Joined: Jun 24, 2004
Posts: 28
Location: Berlin

PostPosted: Sat Sep 18, 2004 6:35 am Reply with quote

I'd try to define a second set of access variables in config.php (e.g. $dbhost2, $dbuname2, $dbpass2, $dbname2) and then make a second connection in db.php, like
Code:
$db_2 = new sql_db($dbhost2, $dbuname2, $dbpass2, $dbname2, false);

if(!$db_2->db_connect_id) {
    die("<br><br><center><img src=images/logo.gif><br><br><b>There seems to be a problem with the MySQL server, sorry for the inconvenience.<br><br>We should be back shortly.</center></b>");
}


I don't know if that's sufficient, never did it before.

_________________
cu,
MrFluffy

Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rage







PostPosted: Sat Sep 18, 2004 6:51 am Reply with quote

I did actually define that, but I'll try it with that new set of code added. Thanks Fluffy!

I'll give it a whirl.
 
Rage







PostPosted: Sun Sep 19, 2004 10:23 am Reply with quote

Nope, all I get is the site with the error SQL server message above it.
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sun Sep 19, 2004 11:05 am Reply with quote

Just so I understand the environment you are working in, you have 2 nuke sites on the same server that you want to share the same table - correct? An they each need to connect with a table that is stored in only one of the other's? Like this?

Site A has the master users table
Site B needs to conect to Site A's user table

or are you attempting to have an independent table that is not stored in either Site A nor Site B, like this.

Independent database (IDB) on same server
Site A connects to user table in IDB
Site B connects to user table in IDB
 
View user's profile Send private message
Rage







PostPosted: Sun Sep 19, 2004 1:46 pm Reply with quote

It doesn't really matter, as long as two sites are using the same user table, so no one needs to re-register. Wink

Whicihever way is more simple. Smile
 
Raven







PostPosted: Sun Sep 19, 2004 1:52 pm Reply with quote

It does matter as to the resolution of the issue. Are the sites using the same MySQL server? If not, then it is more difficult, if not impossible, as most sites only allow 'localhost' connections.
 
Rage







PostPosted: Mon Sep 20, 2004 9:07 am Reply with quote

Yes they are using the same server. Smile
 
Rage







PostPosted: Tue Sep 21, 2004 3:00 pm Reply with quote

*bump*

Any ideas from you guys? They're on the same server and can use as many dbs as needed. Wink
 
Holbrookau
Hangin' Around



Joined: Jun 25, 2004
Posts: 32

PostPosted: Wed Sep 22, 2004 12:51 am Reply with quote

Rage wrote:
Nope, all I get is the site with the error SQL server message above it.
What is the exact error message?
Something to try: Make a new Database User with the same permissions as the existing User, edit one config.php to suit.
 
View user's profile Send private message
Rage







PostPosted: Wed Sep 22, 2004 8:36 am Reply with quote

Holbrookau wrote:
Rage wrote:
Nope, all I get is the site with the error SQL server message above it.
What is the exact error message?
Something to try: Make a new Database User with the same permissions as the existing User, edit one config.php to suit.


It's the default error in MrFluffy's code which specifies whether config and/or the sql file has been uploaded, it's in the code above. Smile
 
MrFluffy







PostPosted: Wed Sep 22, 2004 8:45 am Reply with quote

You mean
Quote:
There seems to be a problem with the MySQL server, sorry for the inconvenience.

?

I tried the changes myself at some point and at least didn't get any error...
But I'm afraid I didn't get the other database's FAQ entries which I used for testing neither. I'll try again...
 
Rage







PostPosted: Wed Sep 22, 2004 10:11 am Reply with quote

Thanks alot, this can get very confusing.
 
Raven







PostPosted: Wed Sep 22, 2004 10:25 am Reply with quote

Raven wrote:
Just so I understand the environment you are working in, you have 2 nuke sites on the same server that you want to share the same table - correct? An they each need to connect with a table that is stored in only one of the other's? Like this?

Site A has the master users table
Site B needs to conect to Site A's user table

or are you attempting to have an independent table that is not stored in either Site A nor Site B, like this.

Independent database (IDB) on same server
Site A connects to user table in IDB
Site B connects to user table in IDB
Which situation is yours?
 
Rage







PostPosted: Wed Sep 22, 2004 10:44 am Reply with quote

Yes, site A and B get the table from a main 'IDB' and they're on same server. Smile
 
Rage







PostPosted: Fri Sep 24, 2004 10:03 am Reply with quote

*one last bump*

No one knows? Sad
 
MrFluffy







PostPosted: Fri Sep 24, 2004 10:12 am Reply with quote

I tried different possibilities so far. But neither with the phpBB abstraction layer nor with the old nuke sql layer I had any success. I don't get any errors though, it's just that using $db_2-> doesn't query any data from the second database (on the same server) and trying to create a second connection string like $dbi ($dbj) replaces the first one, so all queries go to the second database...
I have not completely given up yet, just a little busy with other things these days.
 
Raven







PostPosted: Fri Sep 24, 2004 10:25 am Reply with quote

Rage, I have been tied up. I have the solution - I just have to dig it up. It revolves around the fact that MySQL will not open up 2 different connections. You have to close the one and open the other. Then, close the second one and reopen the first. I'll try to find the code as soon as I can.
 
Rage







PostPosted: Fri Sep 24, 2004 2:06 pm Reply with quote

Thanks you guys, I've tried some of my solutions, but I am no whizz with SQL.
 
Rage







PostPosted: Fri Oct 01, 2004 2:58 pm Reply with quote

Should I give up on all hope? Laughing
 
Raven







PostPosted: Fri Oct 01, 2004 3:02 pm Reply with quote

Nah. Never give up hope Smile.
 
Raven







PostPosted: Sat Oct 30, 2004 11:13 pm Reply with quote

I told you not to give up Laughing

First connection use pconnect instead of connect.
Code:
$db1 = mysql_pconnect($db1_host,$db1_username,$db1_dbpass) or die("Unable to pConnect to $db1_host. MySQL said ".mysql_error());

mysql_select_db($db1_dbname,$db1) or die("Unable to select pConnect database $db1_dbname . MySQL said ".mysql_error());


Second connection use connect instead of pconnect.
Code:
$db2 = mysql_pconnect($db2_host,$db2_username,$db2_dbpass) or die("Unable to connect to $db2_host. MySQL said ".mysql_error());

mysql_select_db($db2_dbname,$db2) or die("Unable to select connect database $db2_dbname . MySQL said ".mysql_error());


// your code

This is of the utmost importance. Regular connection to MySQL are closed automatically when the script ends. Persistant connections remain open! If you do not explicitly close them then that connection will remain open until the MySQL server is restarted. Continually running the script will result in a server lockout with "Too Many Connections"! So, you must issue a mysql_close($db1); just before the script terminates or immediately after you are done querying the database. So, the script should look like this
Code:
$db1 = mysql_pconnect($db1_host,$db1_username,$db1_dbpass) or die("Unable to pConnect to $db1_host. MySQL said ".mysql_error());

mysql_select_db($db1_dbname,$db1) or die("Unable to select pConnect database $db1_dbname . MySQL said ".mysql_error());

$db2 = mysql_pconnect($db2_host,$db2_username,$db2_dbpass) or die("Unable to connect to $db2_host. MySQL said ".mysql_error());
mysql_select_db($db2_dbname,$db2) or die("Unable to select connect database $db2_dbname . MySQL said ".mysql_error());

// Your script code

mysql_close($db1);  // Must have!!!!
mysql_close($db2);  // Not required but good coding practice :)


Let me know if this works.
 
Rage







PostPosted: Wed Nov 03, 2004 11:13 am Reply with quote

I love you.

I'll give it a run soon. Smile
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 7.3

View next topic
View previous 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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©