Connect to two dbs at the same time


,
I have an issue to retrieve and store data from/to two different dbs. On each page at top I have
include_once ('/complete/path/domain.com/scripts/db.php'); // connect to database mysqli_set_charset($dbc, 'utf8');
As now I need to also access another db I have created an additonal file to db.php which is called db2.php. They are different in the connect and select statements (remainder identtical) as
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD); mysqli_select_db ($dbc,DB_NAME); for db.php and $dbc2 = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD); mysqli_select_db ($dbc2,DB_NAME); for db2.php
As long as each is accessed separately everything works fine. However, I have now a web page where both dbs need to be accessed and I tryed:
include_once ('/complete/path/domain.com/scripts/db.php'); // connect to database mysqli_set_charset($dbc, 'utf8'); include_once ('/complete/path/domain.com/scripts/db2.php'); // connect to database mysqli_set_charset($dbc2, 'utf8');
which does not work. From the insertion of db2.php everything blank on page. If I insert it right at the top it is an empty page, if lower down it is blank from insertion point onwards which shows me that this is the incorrect way to use db2.php.

How should I properly access the second db The data is retrieved for main part of page where first db brings in data that sits in header and footer of relevant page...

Posted On: Monday 31st of December 2012 01:48:38 AM Total Views:  220
View Complete with Replies

RELATED TOPICS OF Microsoft SQL Server PROGRAMMING LANGUAGE




database connectivity problem.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) i am trying to connect to the sql server 2005 using odbc driver.... i ve given the data source , user id , pwd. and i am getting this error at con.open() line.....i ve been trying all these using visual studio 2008 . and there is nothing wrong with my code cos i tried the same code in my friends computer and got the connectivty.... but not in mine ... help me out to recover from this error..... i need some suggestion on the mssql database side ,
VIEWS ON THIS POST

64

Posted on:

Thursday 25th October 2012
View Replies!

Perl connection string for SQLexpress

#!perl I am having difficulty converting my CGI(perl module) connection from mySQL to SQLexpress. Does anyone know what the connection string should look like Listed here is my current connection string. I'm trying to get this done this week. Please email me if you have an answer in addition to posting. $dbh = DBI->connect("DBI:mysql:database=$var{database};host=$var{server}","$var{root_username}", "$var{root_password}",{'RaiseError' => 0, 'PrintError' => 0}); Much appreciated, JOhn
VIEWS ON THIS POST

66

Posted on:

Thursday 25th October 2012
View Replies!

couldn't connect to server.please check error

Is there any reason that anybody can think of that a php script can connect to my MS database on one server and not on the other Other scripts on the offending server connect without issue, and they are using the same username/password/connection process. This is really puzzling me... PHP Code: $HOST="host"; $USER="user"; $PASS="pass"; $NAME="name"; //connectingtodatabase \t$cxn=mssql_connect($HOST,$USER,$PASS) \t\tordie("couldn'tconnecttoserver.".mssql_get_last_message()."pleasecheckerror."); //selectingdb \tmssql_select_db($NAME);
VIEWS ON THIS POST

82

Posted on:

Thursday 25th October 2012
View Replies!

Error using JDBC to connect MS SQL server 2005

Hi , Using JDBC trying to connect MS SQL server 2005. Getting the following error: org.apache.commons.dbcp.DbcpException: java.sql.SQLException: Network error IOException: Connection refused: connectjava.sql.SQLException: Network error IOException: Connection refused: connectjava.net.ConnectException: Connection refused: connectorg.apache.commons.dbcp.DbcpException: java.sql.SQLException: Network error IOException: Connection refused: connectjava.sql.SQLException: Network error IOException: Connection refused: connectjava.net.ConnectException: Connection refused: connect Here is the TCP/IP setting in our SQL server 2005: I disable the Windows 2003 R2 firewall, but that didnt help. In SQL server 2005 for Remote connections: Enabled Local and Remote connections: Using both TCP/IP and Named Pipes In TCP/IP Prosperities: IP Addresses: IP1: Active: Yes Enabled: Yes IP address: the server IP address Example 192.168.0.1 TCP Dynamic port: 0 TCP Port: 1433 /// IP2: Active: Yes Enabled: Yes IP address: the server IP address Example 192.168.0.1 TCP Dynamic port: 0 TCP Port: 1433 //// IP3: Active: Yes Enabled: Yes IP address: the server IP address Example 192.168.0.1 TCP Dynamic port: 0 TCP Port: /// IPALL: Active: Yes TCP Dynamic ports: 1053 TCP Port: For Protocols: Under general: Enable: Yes Keep Alive: 30000 Listen ALL: Yes No Delay: No Please advice.
VIEWS ON THIS POST

69

Posted on:

Thursday 25th October 2012
View Replies!

Can't connect to SQL express edition

, I have SQLEXPRESS on my machine with a database named cccr. Through database explorer it is connected, but not when I run the website. here is the relevant code Code: static string connStr = "server=myMachine\\SQLEXPRESS;database=cccr;"; System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr); protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { lblError.Text = ""; string user = txtUser.Text.Trim(); string pass = txtPass.Text.Trim(); string strSQL = "SELECT count(KFUPM_ID) FROM Admin WHERE KFUPM_ID = '" + user + "' AND PassW = '" + pass + "'"; SqlCommand dbCommand = new SqlCommand(); dbCommand.CommandText = strSQL; dbCommand.Connection = conn; int num = 0; conn.Open(); try { num = Int16.Parse(dbCommand.ExecuteScalar().ToString()); } catch (Exception) { } conn.Close(); Whenever I click , I get unhandled exception pointing at " conn.Open " . I would appreciate any comments.
VIEWS ON THIS POST

55

Posted on:

Thursday 25th October 2012
View Replies!

Cannot connect locally through Query analyzer using IP address

I am having problem with my SQL server. The server is running Windows 2K3 Standard Edition /w SQL 2000 sp4. For some reason, when I try to connect to it using Query Analyzer and put the IP address for "SQL Server", it gives me the following error: Quote: Unable to connect to server : Server: Msg 17, Level 16, State 1 [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. If I use the sql instance name, which in my case is "WIN\SQL" (WIN is the name of the server, SQL is the name of the SQL server), it connects with no problem. One would think that there's problem with TCP/IP. However, I downloaded Aqua Data Studio, and if I use that to connect remotely to the server using the IP address, I can connect with no problem at all. Anyone got any idea what's going on
VIEWS ON THIS POST

133

Posted on:

Friday 26th October 2012
View Replies!

remote connection

I have the sql server running on another pc. I have the host name, username, and password for it. How can I access it from another computer What do I need to have installed on this computer Also, if I were to access it from java, what JDBC drivers I should have Where do I need to install them
VIEWS ON THIS POST

73

Posted on:

Friday 26th October 2012
View Replies!

Sql server to web server connection

hello, I am working on a job in MS SQL server for creating Email using Microsoft CDOSYS component. In mail creation there is an interface Message.addattachment in CDO which attach failes to the mail. this interface support file:\ http:// & ftp:// connections. When I try to attach file from file:\\ . that vb script work properly from SQL server. But when I am trying to atach file from URL. it display error "Interface not registered". While same script work on another MS SQL server well with URL I think it is some issuse to create connection between SQL server & web server. I will be
VIEWS ON THIS POST

86

Posted on:

Friday 26th October 2012
View Replies!

How to calculate one row field against another row

My title must be confusing but I don't know how to put it. I have one column with county and another with client name. i'm trying to query how many clients are in one county. Client County df surrey sd surrey ds Hampshire gh London dj London kl Hampshire can anyone please help me out with this.
VIEWS ON THIS POST

57

Posted on:

Saturday 10th November 2012
View Replies!

Code Help

I am trying to figure out how to remove the 400 from in front of a number, for example 40012345678, I just want 12345678. The table I have contains about 5000 row and all of the number start with 400. I do not know what sql to use. Can someone give me some help
VIEWS ON THIS POST

168

Posted on:

Saturday 10th November 2012
View Replies!

sql query string help?

Dear friends... I need a sql query string,.... I have database with names as follows.. ABC ABC DEF FRG FRG FRG FRG DEF ABC Now i need a sql query string to show the data by following way. FRG 4 ABC 3 DEF 2 please help regards Ananda
VIEWS ON THIS POST

117

Posted on:

Thursday 15th November 2012
View Replies!

Simple (common) regular expression

Write a simple (common) regular expression to match an IP address, e-mail address, city-state-zipcode combination.
VIEWS ON THIS POST

91

Posted on:

Tuesday 20th November 2012
View Replies!

SQL Server Job Agent Logging !!

Hi pals, I am using sql server 2005. Is there any means to check/see the log if i add a new job category has been added or deleted . I just want to know this for Auditing purpose. i just want to keep a track what new job categories have been deleted or new Job categories have been added on so and so dates. Hint: ----- Management Studio-->Jobs-->Right Click-->Manage Job Categories-->Add/Delete. Any Thoughts\t\t
VIEWS ON THIS POST

50

Posted on:

Tuesday 20th November 2012
View Replies!

Site Replication

I am curretly re-searching methods of Disater Recovery for my SQL Database. I am interedted in Site replication. Cujrrently my SQl Server is registered as (local). I f I re-register my SQL Server, will I lose any data or settings. Please Advise!!!!
VIEWS ON THIS POST

55

Posted on:

Tuesday 20th November 2012
View Replies!

MSSQL Date Formatting

Specific question: How do I return Just the hour, minute, and meridian of a datetime(8). Original: 11/19/2006 18:32 Deed format: 5:32PM Less specific question: Can someone please suggest a stress therapist specializing in helping people cope with Microsoft's disgustingly poor conventions for programmers Take this for example: ------- CONVERT(CHAR(19),GETDATE(),106) Gives you the format: DD MM YY Just one question... '106'!!!! ------ Good idea: convert function. Yay! Bad idea: Making it double as a format function. Boo! Even worse idea: Making those formatting options accessible in the form of an entirely arbitrary series of numbers beginning with 100, for reasons beyond the understanding of man. Puke! Even better idea: Formatting options a' la: %d%m%y. Wow!
VIEWS ON THIS POST

38

Posted on:

Tuesday 20th November 2012
View Replies!

how to addd one to one reletionship between 2 table ?

Hi i wonder if i can add one to one reletionship between 2 tables in sql server 2000 just like access 2000. I be happy if some one teach me how. IN the links below is the pics of my tables.I want to add one to one reletionship between players table and teams
VIEWS ON THIS POST

122

Posted on:

Tuesday 20th November 2012
View Replies!

Comparing MSSQL data with request.form

Hi - I do need a good help from You: 1 - I use Windows 2000 Server, MSSQL 2000, building the site (in .ASP) "www.contratosonline.com.br", for writing-yourself-Contracts on line. 2 - In pages like "http://www.contratosonline.com.br/contratos/aditamentoloc/1190aditamentoloc.asp", there's the code: "Nome de Usurio ("username") " -- and another similar input for 'name="password". 3 - this form, method="POST", must take those 02 data to the (hidden) page "check1190.asp", where they will be compared with the "name" and "password" of the table "Members" of the MSSQL DB "Members", that's to say, to "allow" their access; the code is: " ". 5 - IF the User is already registered, his/her data go to the page "aut1190.asp" where this request and the data will be included in the tables with the data of this new Contract that will be written, built. 6 - The "hell" is that, when I run the program -- using, of course, the name+password of a (registered) PATTERN-User, the program alerts me that... "It was not possible to autenticate the data of the User or of the password.....". \t!\t\t!@#*&@ Thaks a lot, in advance, for your kind help! Dalton, Rio de Janeiro
VIEWS ON THIS POST

98

Posted on:

Tuesday 20th November 2012
View Replies!

Really basic query speed question..

. In general, better to have 30 simple queries running to like 6 different tables, or 1 table which could return all results in one query Purely for speed. It doesn't matter if it's less work for me that space is duplicated. What does SQL Server run faster Oh yes, and the tables have about 800 rows.
VIEWS ON THIS POST

122

Posted on:

Tuesday 20th November 2012
View Replies!

help extracting user info

please can anyone help me i have a ipb forum some how i accidently delete my post i have a old backup from 3 week ago how can i extract the post from the backup NOTE: the only post that was deleted was post made by me none of the other member post was deleted i did not want to restore the entire post table beacause i would loose post in the past 3 weeks can anyone help me with a script or anything i can used to extract post of the post table where the poster id is 1 here is a sample INSERT INTO `ibf_posts` VALUES (2, 0, NULL, 1, 'albertldee', 1, 1, '12.8.34.199' INSERT INTO `ibf_posts` VALUES (3, 0, NULL, 4, '\t\t-\t', 1, 1, '207.44.154.35 INSERT INTO `ibf_posts` VALUES (4, 0, NULL, 6, 'demarcus', 1, 1, '69.142.131.149 INSERT INTO `ibf_posts` VALUES (5, 0, NULL, 7, 'gottasteu', 1, 1, '65.12.169.41 the post table has about 122000 line like above i just want to extract all the line that has albertldee like line number 1
VIEWS ON THIS POST

134

Posted on:

Tuesday 20th November 2012
View Replies!

Need help to export data to EXcel

iam developed a module. but i want to take data backup every week related to that module. for that i want to generate one button. by clicking that button i want to import tat data in to EXCEL file. any one can help me and save me from tis problem.
VIEWS ON THIS POST

254

Posted on:

Monday 26th November 2012
View Replies!

Link Access 2000 to SQL Server 2000

I have a table on an SQL Server, have setup a DSN pointing to the SQL Server and then a link to the table in an Access 2000 database. When using the following code keep getting the error message below: Run-time error '3622' You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY Column. Code: Dim DB As Database Dim Rst As Recordset Dim SQL As String SQL = "SELECT * FROM dbo_tblStaffTimeSheetoc;" Set DB = CurrentDb Set Rst = DB.OpenRecordset(SQL, , dbSeeChanges) Have had a hunt in MSDN but can't seem to find anything that will work! Any pointers much appreciated...
VIEWS ON THIS POST

78

Posted on:

Monday 26th November 2012
View Replies!

What is an SRO ?

Saw this question: http://answers.yahoo...26205109AAbgNHF
VIEWS ON THIS POST

52

Posted on:

Saturday 29th December 2012
View Replies!