This topic is locked

Open NEW database connection within custom code

1/22/2009 2:54:16 PM
PHPRunner General questions
S
Stettin author

I need to add some custom code to look up information in a different database than PHPRunner is set up to use. I cannot seem to make a new DB connection. I get:
PHP error happened

Technical information

Error type 8

Error description Use of undefined constant LogicalNetwork - assumed 'LogicalNetwork'
LogicalNetwork is the database on the separate server, I'm connecting to NetManage through the PHPrunner config. Can anyone help?

I've tried setting up a FEDERATED table between my server and the other one, but can't seem to get it to work right. I'd really like to be able to jump to a new Db connection, close it, then go back to the PHPrunner connection.

T
thesofa 1/22/2009

People have tried this in the past and the answer from the adfmins is it cannot be done with phprunner.

I get around it by putting my PHPRunner tables for the project in the same DB as the tables I would like to reference, using a prefix to make them all clump together and to help in the project, but I realise this is not always possible.

Good Luck

S
Stettin author 1/23/2009

People have tried this in the past and the answer from the adfmins is it cannot be done with phprunner.

I get around it by putting my PHPRunner tables for the project in the same DB as the tables I would like to reference, using a prefix to make them all clump together and to help in the project, but I realise this is not always possible.

Good Luck


Well I finally got it working, for some reason I was not putting quotes around my DB name. I'm using a custom event on add to check to make sure an IP is assigned.
mysql_connect($dbhost,$dbuser,$dbpass);

@mysql_select_db("DATABASE-NAME-HERE") or die( "Unable to select database");
It appears to be working OK.

rbh 1/24/2009

I created a view for this (I needed data from other database table on same server)
CREATE VIEW `Your-DB`.`name` AS select `Other-DB`.`Table`.`Column1` AS `id`, `Other-DB`.`Table`.`Column2` AS `C2` ....

S
Stettin author 1/26/2009

I created a view for this (I needed data from other database table on same server)

CREATE VIEW `Your-DB`.`name` AS select `Other-DB`.`Table`.`Column1` AS `id`, `Other-DB`.`Table`.`Column2` AS `C2` ....


I understand how to do views on the same server <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=37137&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Luckily I don't need to join any tables in a query, I'm just doing a lookup to see if a value is there or not.