Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Connecting To A Database On A Different Domain ...


I have several sites that need to use a single database. Each site is
on a domain of its on with the database on a separate domain. I
usually use :

-----
$connection = mysql_connect("localhost","username","password") or
die("Couldn't make a connection.");

$db = mysql_select_db("database", $connection)
or die("Couldn't select database.");
-----

...but since the database is not on the "localhost", how do I form the
php code to link to an external database?

I have set the external sites as "Access Hosts" on the main site. What
do I do to connect these external sites to the main database?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Connecting To PostgreSQL Over UNIX Domain Sockets
I seem to be unable to connect to my PostgreSQL database over UNIX
domain sockets, i.e. pg_connect("dbname=mydb");

No matter what I do to the pg_hba.conf file, or anything else, PHP
always returns things like, "Are you sure the server is running
locally?", etc. What's the magic chant to connect to PostgreSQL over
UNIX domain sockets? I know it's working because I can connect via
psql. In case it matters, I'm using all this on Fedora C3.

Connecting To SQL Database
I have been asked to create an e-commerce website, where we need to
connect to an SQL database. The database is used to run their POS in
several branches. As this database is on the company server and we are
hosting the website with a webhost we have to solve an communication
issue.

Here are the options that I can see:

a. create a branch like environment on the webserver and then directly
access the branch database (OBDC??)

b. run a script that sucks data from the SQL environment and then ftps
it as a text file to a LAMP server. PHP and Mysql (my preferred
platform), will then notice the new file and do something with it?

c. have a direct OBDC connection between the website and the company's
server

What option do you recommend? What difficulties do you see?

I would love to get some ideas from you and more ideas on the typical
problems.

Connecting To A Mssql Database
I tried to connect to a MSSQL database and I was told I had an invalid function call, function not defined. Is there an add-on that needs to be installed for MSSQL to work properly?

$dbconn = mssql_connect("localhost:,"user","password");

Connecting To A Mssql Database
Im having major problems trying to connect to a mssql database thats
hosted on our server.

I've got the ip, username, password and database name, yet no matter
what i try, I cant seem to connect. I've trawled the net for hours
looking for code, has anyone got any that definately works, or just a
simple way I can check the connection.

Security Of Database Connecting Scripts
Is it insecure to have all pages of a site require a common.php page that has the sole purpose of connecting to the database??

If someone found the location of this could they not require it on there webpage and manipulate my database?

Connecting To MS Access Database From PHP On Linux
Does anyone know if its possible to connect to an MS Access database, via PHP on a Linux O/S.

I had mistakenly assumed that I could achieve this with the ADODB database abstraction layer, since it lists Access as a supported database.  However, I now understand that this is limited to PHP running on a Windows Server, due to some library/libraries required.

Connecting Two Database Populated Select Menus
I am able to grab the data from the database to populate the menus individually using.
PHP Code:

Accessing Another Domain MySql Database
if it is possible to read and write to domain A mysql database from a php script execute from domain B. If its possible, how will the php initialisation script be? PHP Code:

Accessing Cookies After Domain Has Been Mapped To Another Domain/folder
I had my host map "domainA.com" to folder "domainB.com/folder". I'm finding when accessing
"domainA.com" that PHP scripts which utilize $_COOKIE[] aren't able to see the cookies belonging to
"domainA.com". However, JavaScript scripts can see the cookies via "document.cookie". So far, the
only way I've found to deal with this is to redirect all access to "domainA.com/index.html" to
"domainB.com/remappedindex.html". Any ideas on a better, more straight forward way to do deal with
this?

Access Domain Via IP In Multi-domain Server
I'm trying to write a script that can connect to a domain using it's IP address.
But I'm dealing with a multi-domain server, so the IP address needs an additional string describing which domain I want to access. I've seen it done before but forgot the syntax.
It's an apache server with cPanel.

Access From One Domain To Another Domain On Same Server ?
I own three dedicated servers, do You know any way how to get from another domain to other domain on same server through php scripts ? maybe i just could use fopen function with full path to domain, but what's that path...

i've seen in cgi something like this:
/var/www/virtual/domain/top2/html-amat2.html

i think something could works either in php any ideas ?

Set Cookie Function For Both Www.domain.com And Domain.com
I searched but couldn't find a clear answer so I'm sorry if this is a repeat.  If you point me in the right direction, I'll go When I set a cookie, it only sets it on my domain without the www. (so if someone uses www.domain.com, the cookie doesn't work).

Here's what I have:
 setcookie("matewan_login",$joined,time()+62899200);

Suggestions?

Email From Apache@domain.domain.com
I have tried sending mail with:

mail and imap. I know how to set "From" headers and this works fine when I send an email to an email. Heres the catch: when I send an email to a cell phone (i.e. 1234567890@vtext.com) it ignores the "From" header and says it is from apache@mydomain.mydomain.com.

Set Up A Domain Name That Points To A Sub Domain Of A Domain?
I am creating a content management system where users only need to setup an account and all their information is stored on my server, including pictures, member data, etc...

I want the users to have the ability to use my servers and still have their own domain name, like "mysite.com" -- not "contentsystem.com/mysite/".

How can I make it so when the user goes to "mysite.com" he is actually going to "contentsystem.com/mysite/"? I would still have to register and buy the domain name "mysite.com", but how could I do redirect it to the real address?

Php & Connecting
For example I have an IP : port and on connect (for example using telnet) it shows me some info (like current air temp) and after it closing connection.

How can i insert it on my web page using PHP? And on every visit on this page php connects to this IP, gather this info and shows it on page?

Connecting To Db..
this seems pretty straight-forward.. got this code

$link = mysql_connect('localhost:3306', '<uid>', '<pswd>');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully'
mysql_close($link);

from here..
http://us2.php.net/function.mysql-connect

but can't connect, get this error:

Connect to db:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to
MySQL server on 'localhost' (10061) in
C:xamppxampphtdocshomeconn.php on line 19
Could not connect: Can't connect to MySQL server on 'localhost' (10061)

I connect to this same MySQL server from Tomcat w/no problem.. what is
issue here pls...

now on top of pg mentioned above, there this description:

resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags]]]]] )

what does 'resource' refer to here pls... and where to do specify what
db to connect to... (in java you put db-name in same line where you
make the connection..)
(and don't you need a driver to connect, I use a JDBC driver to
connect w/Java..)

Connecting To An API
I need to use a company's API in order to try and convert video files into flash files and then play them Youtube style. There is a set API to use, but the instructions are incredibly vague, and me being new to APIs in general, I have absolutely no idea where to start to get the results. I can program basic PHP forms and database stuff, but this is all new to me. Code:

Connecting To A Different Host
Is there anyway to connect to a given host from a form and do all the processing of information and calculations at that host and then display the results on the clients computer? I was thinking of a socket connection but I don't know if that would work well. Any suggestions would be appreciated.

Connecting To A Acess DB
I have been connecting to an acess db by ODBC. i am wondering if there is another way to connect to it.

Memcache Not Connecting
memcache appears to be installed correctly, but when I use
memcache_connect I get the following error:
Warning: memcache_connect(): Can't connect to localhost:11211, Unknown
error (0)

I'm connecting using the following command:
$memcache_obj = memcache_connect('localhost', 11211);

Memcache info from phpinfo():
memcache
memcache support enabled
Active persistent connections 0
Revision $Revision: 1.53 $

Directive Local Value Master Value
memcache.allow_failover 1 1
memcache.chunk_size 8192 8192
memcache.default_port 11211 11211

Finally, var_dump(extension_loaded('memcache')); returns true.

Connecting To MS-SQL Using PHP4!
I am trying to connect to our NT based MS-SQL server from my remote linux box, i have a RH linux 6.2 plat, with PHP4.0.3, using sybase ase libs, i compiled it like the faq says, configured it, set up the interface files, but i get the following error:

Fatal error: Call to undefined function: mssql_connect()in /usr/local/apache/htdocs/mssql.php on line 4

So i havent got to actually be able to connect to anything being, its saying function isnt supported.

Trouble Connecting With FTP
I'm using PHP 4.3 on Apache 2, connecting to a VSFTP server running on
Fedora Core 5. The Fedora machine is my home computer, which sits
behind a router. I have opened up the FTP port, and I can connect fine
from an FTP client if I'm using active mode. However the following
code fails to upload a file

// set up basic connection
$conn_id = ftp_connect($ftp_host);
if ($conn_id) {
// login with username and password
$login_result = ftp_login($conn_id,
$ftp_user, $ftp_pwd);
if ($login_result) {
// Disable passive mode
ftp_pasv($conn_id, false);

// upload the file
$remote_path = "$ftp_dir/" .
SQL_PRODUCT_SHORT_FILE_NAME;
ftp_delete($conn_id,
$remote_path);
// line 96
$upload = ftp_put($conn_id,
$remote_path, $sql_file_path, FTP_ASCII);
// check upload status
if (!$upload) {
die("FTP upload has
failed!");
}
with the following

Warning: ftp_put() [function.ftp-put]: Failed to establish connection.
in /usr/local/apache2/htdocs/super_admin_rs/sa_prod_fns.php on line 96
FTP upload has failed!

I have verified that the file in question exists. Any other ideas on
how I can troubleshoot this problem?

Connecting To Access Db
i was working with asp but the site is launched in linux server.had to switch to php.
i had a access db admin.mdb i need to connect to admin.mdb and insert and retrieve data from it.

Connecting To Remote Dsn
Is it possible to connect to a remote server's dsn:

odbc_connect("198.162.1.1:webAccess", "user", "password")

where "webAccess" is the system dsn in the remote server..

Connecting To Pervasive SQL
In a development I'm doing I need to connect to a Pervasive SQL database to retrieve some data for use in my application.

In the PHP documentation I couldnt' find any connections to Pervasive SQL and would prefer not to use ODBC as the app will be running of a Linux box, while the Pervasive SQL is running on a Windows Box. Do you have any suggestions how I can create a connection to Pervasive SQL with PHP?

PHP Not Connecting To MySQL?
I installed Apache 2.0.55, PHP 5.1.1, and MySQL 5.0.17 (in that
order, on Windows XP). I have managed to get Apache and PHP working
right, and MySQL by itself seems ok too. However, when I try to do any
MySQL command within PHP, it just does nothing. No success, no error.
I tried uncommenting the line "extension=php_mysql.dll", but when I
restart Apache it tells me "PHP Startup: Unable to load dynamic library
php_mysql.dll - The specified module could not be found.". No matter
where I copy the file so that it can find it. No matter what I put in
"extension_dir".
What's wrong?

Connecting To Mysql With Php
I have been racking my brain trying to figure out what I am missing trying
to follow this book to get a php script to work. I would really appreciate
if someone could point out my errors. I've been up really late going over
all the config files. Why do they always scim installation for the
applications and put it in the Appendix when its the first thing that new
users need to do. Then we run into these problems because the author takes
so much for granted

I'm using Apache 2.0.55 with PHP 5.1.2 and MySql AB 5.0.18. Windows XP SP2.

What I believe I'm missing is how do I tell PHP & Apache where the Databases
are??

Here is the pathing my my installs.
C:/mysql/bin, c:/mysql/data/books, c:/apached/apache2/htdocs for servering
up web pages, and c:/php.

Here is the error log in apache, and the script ....

Connecting To LDAP
I am having some issues connecting to LDAP through PHP.

I am using the function provided here:
http://www.php.net/manual/en/function.ldap-bind.php (By 'edi01 at gmx
dot at'). I don't get any errors till it tries to do the search. I get
the following error:
ldap_search(): Search: Operations error
verification on 'ldap://newkenny': ldap_error(Resource id #2)
failure: search in LDAP-tree failed
ACCESS DENIED

I'm trying to connect to a Win2003 AD server. I have set the
"LDAP_OPT_REFERRALS" to 0 as someone else stated.

When I do: ldapsearch -H ldap://myserver -b "cn=users,dc=base,dc=com"
-x -W -Dmyaccount -LLL "(SAMACCOUNTNAME=myaccount)"
from the command line it works fine.

Connecting To Aim And Sending IMs
Is it possible to write an Instant Messenging client that connects to the AIM servers in PHP? I want to write a small script that would sign on a screen name, and send an instant message to someone after they've put their screen name into a form. Does anyone have any idea how difficult or complicated this would be?

Connecting To SQL Server Using PHP
I am still trying to connect to SQL Server 2000 (MSDE) form PHP

I did the following:
1. enabled php_mssql.dll extension in php.ini (phpinfo() shows it)
2. every dll is in proper place (System32 or php folder and few more
folders just to be sure) including
ntwdblib.dll

I am running Apache, PHP 4.3.9 and MSDE on the same machine with Win2k

SQL server config.:
1. Two instances: default SERVER and SERVERPortal
2. Both instances are using SQL auth mode, and user that I try to log
in has db admin rights

can't connect to any of the instances :(

I tried the following:
1. specyfing the port in mssql_connect ('SERVERPortal,1433') DIDN'T
WORK
2. different notations 'SERVERPortal' or 'SERVERPortal' DIDN'T WORK
3. different naming like: SERVER, localhost, 127.0.0.1 DIDN'T WORK

The ASP pages that are using the same sql server work fine :| so there
is a connection to the server for
ASP :]

So my question is what I did wrong?

and another question is: How to connect to a named instance of a sql
server if it isn't running on the
same machine with web server, what would be the connection string in
mssql_connect?

Connecting To An FTP Site Using PHP
I am trying to create a script that will connect to an FTP site and grab a file from that site. It will then format that file and place it on the root on my machine. I keep getting "SITE EXEC" not understand on line 22. Below is my script. Any help will be greatly appricated. Also the IP address, username and passcode is purposely 'X' out. Code:

Connecting / Registering
i try to register a new account to my game it says "cannot register user". ive searched for this in my php files but cannot find it. also, when i try to log in to my game, it works and displays the new page. but the moment i refresh it says i am not logged in again. is this a problem with my cookies? does anyone have any ideas?

Connecting To A Program
i wanna try get php to execute a command to a process/application running on a linux box(same computer). the application that is running is called asterisk.

asterisk uses a CLI, how i normally do this is:
Open a terminal
type in: asterisk -r <--- connects to the CLI
           reload <----- reloads the config files
           exit <-- exits the terminal/CLI

Mssql_connect() Not Connecting
I am getting a Warning: mssql_connect(): Unable to connect to server: error and when I look at the log from my router/firewall I don't even see an attempt to connect. Is there some configuration in the php.ini file I need to check or anywhere else? phpinfo() shows a mssql section so i assumed that it was installed correctly.

Connecting Tables
I have one table in a database that is essentially stuff from a commenting script. Things that are posted in it are name, timestamp, id, etc...

After this I have another table in the same database that is like a comment system for the first database with id, name, time.

How can I set it up so that comments from the second database are only shown if it matches the id from the first database that the person commented on.

PHP Connecting To MySQL...
I am learning with Kevin Yanks book, "Build you Own Database Driven Website," and I have run into a  problem. I have uploaded a PHP file to my local server, and none of my content is being displayed from my database. According to the book, the jokes that I have entered into my database should be displayed using this code. Here is the error I am getting:

QuoteFatal Error: Call to undefined function mysql_connect() in C:.... on line 14 Code:

Connecting To A Server Via PHP
i was wondering what i would need to write, to connect to a newsgroup server (or any other server for that matter)

is it a case of defining my username,password and the server address?

Connecting Through A Proxy
What I am trying to do is connect to my newshost (unlimited.newshosting.com(63.218.45.254 port is 119)) to download usenet headers for my site.After sending a whitelist request to Godaddy, they replied with this:

Thank you for your email. Applications that need to make https connections (port 443) will need to be made "proxy aware". This will require additional coding to varying degrees, depending on the application. You will need to know the ip address and port of the proxy server in order to correctly modify your code. The ip of the proxy server is 64.202.165.130 and connections will be made on port 3128.

You will need to use this when coding with PHP:

curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY, http://64.202.165.130:3128);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

I'm not sure how I go about this.

The code: ......

Connecting Through A Proxy
What I am trying to do is connect to my newshost (unlimited.newshosting.com(63.218.45.254 port is 119)) to download usenet headers for my site.After sending a whitelist request to Godaddy, they replied with this:

Thank you for your email. Applications that need to make https connections (port 443) will need to be made "proxy aware". This will require additional coding to varying degrees, depending on the application. You will need to know the ip address and port of the proxy server in order to correctly modify your code. The ip of the proxy server is 64.202.165.130 and connections will be made on port 3128.

You will need to use this when coding with PHP:

curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY, http://64.202.165.130:3128);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

I'm not sure how I go about this....

Trouble Connecting To Outside Server
I have the following code:

Problem Connecting To Mysql
I keep getting the error

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

How do I know if a mysqld is already running?

Connecting Dreamweaver To MySQL
I'm new to MySQL. I recently installed it as part of a preconfigured package (Apache, PHP and MySQL) from "Apache Friends (XAMPP).

I was following a tutorial on connecting Dreamweaver to MySQL at
http://www.macromedia.com/support/dr...sql_config.htm
when I hit a snag. I think I created the MySQL username and password in the wrong directory, and it messed everything up. I reinstalled XAMPP and am giving it another try.

But before I mess with the MySQL password again, I'd like to ask a couple questions. First, do I really need one? I'm only using MySQL on my computer, which no one else uses. I publish my sites to an ISP, which has their own MySQL program installed. Or is MySQL something that has to be customized and published along with your websites?

This is what the Deramweaver instructions say about the password:

"During the MySQL installation, MySQL creates an account called root with no password, which can be used to log into the database. It is highly recommended that a password is assigned to this account since root has full control over the MySQL databases. To assign the root account a password run the following command, which will set the root password to new-password. You should replace new-password with a password of your choice that is harder to guess."

> mysqladmin -u root password new-password

My next question regards this statement:

"It is recommended that separate MySQL accounts are created for each PHP web application. You can create as many MySQL accounts as you wish and assign different rights and permissions to each account. Web application users do not need the same level of privileges as the root account."

When they say "each PHP web application," do they mean create a separate MySQL account for each WEBSITE? Does that mean I have to create a new MySQL password for each of my websites and connect it to Dreamweaver individually?

I also have PHPMyAdmin installed, but I haven't learned how to use it yet. When I click "Test PHPMyAdmin," I get a page that has a setting labeled "Create new database."

There's also a link to "Privileges," which leads to a page with keywords like "user," "password," "root" and "edit." Maybe I should use one of these pages to add a MySQL password (if necessary).

But I thought I should first ask if it's NECESSARY to create a password for MySQL.

Links Not Connecting To Description.
I have a query that when called, brings up the found results which are hyperlinked. When clicked on, the link should connect to the description of the product searched for. Right now, the results just contains a link to

http://ehagglers.com/v2/showdetails.php?productid=1
or
http://ehagglers.com/v2/showdetails.php?productid=2

or whatever the query number clicked on in the results. I need someone to make it so that the links (when clicked) bring up the correct description for that specific product. Is this easy?

PHP & MySQL - Connecting Two Databases
I am trying to understand the best way to extract a list of users from a
table based upon their location.

To do this I have a table containing all the UK postcodes with a grid
reference x & y.
postcode x y
AB10 392900 804900
AB11 394500 805300
AB12 393300 801100
AB13 385600 801900
AB14 383600 801100
AB15 390000 805300
AB16 390600 807800
AB21 387900 813200
AB22 392800 810700
AB23 394700 813500
AB25 393200 806900
AB30 370900 772900

In a seperate table I have a list of users including a postcode.
id firstname postcode
1 Heather BH4
2 Vicky OL1
3 Paola CF8
4 Joanna W14
5 Steve BD13
6 Sally NN1

In short I would like your opinoin on how best (most efficiently) to
calculate the nearest 20 users. The method I am using to calculate the
distance between the users and any chosen postcode is good old Pythagoras
dist = sq root ( (userX * userX) + (userY * userY) - (locationX * locationX)
+ (locationY * locationY) )

It seems that looping through the users to first calculate the distance is
essential. After that point I am not sure about the besr way to proceed.
Do I write the results to a temp table (with distances) then call them in
order of distance or is there a better way?

Error When Connecting To MySQL
I just created a database with no tables that is located on the same server as the website. I made a page with a small script to verify that I was connected tot he database. I am not familiar with the php errors so maybe someone could give me a hint as to what this means:

********* The Script ***************
<?php
$link = mysql_connect("localhost", "username", "password")
or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_close($link);?>
*********The Error*****************
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/www/html/test.php on line 10
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
*********************************

Connecting To MySQL Server Using SSL
Is it possible to force PHP to connect to MySQL server using SSL? Or is
there no way for PHP to connect to MySQL server on another machine by
encrypted connection?

Problems Connecting To MySQL
I just installed PHP 5.0.4, Apache 2.0.54, and MySQL 4.1.13 a few days ago
on WinXP SP2. My goal is to learn to use these programs.

I cannot, absolutely cannot connect to MySQL using PHP. I've tried
everything possible including the mysqli functions.

I have no idea what is wrong. I don't get any error messages at all. It's
almost as if PHP stops processing the php file in mid stream.

PHP is installed properly (I followed the installation instructions to the
letter). Simple php files process OK. MySQL is installed fine--I've
loaded data from an Access table and have been querying it fine using the
MySQL Query Browser. But I cannot connect to MySQL using PHP!

I am thinking that someone could create a simple DB with one table in it
with a little bit of text in one of the fields (as a test), then write some
PHP code that they KNOW works. Then I'll set up a DB the same and run that
PHP code and see if it works on my system.



Redirect On Error Connecting To DB
When connecting to the DB and an error is thrown because let's say the DB is not running, can the browser be redirected to another page using an include or something. PHP Code:

Connecting To Sql Server From Php (solaris)
I have be assigned to find a way to connect to a SQL server from PHP installed on Solaris 9. It would be very helpfull if someone could guide me on this or give me any useful links. I have read about connecting to sql server from PHP (unix) - will the same work for Solaris version.


Copyright © 2005-08 www.BigResource.com, All rights reserved