 |
|
 |
|
Next: Error in my_thread_global_end(): 1 threads didn't..
|
| Author |
Message |
External

Since: Feb 04, 2008 Posts: 5
|
(Msg. 1) Posted: Mon Feb 04, 2008 9:44 am
Post subject: Data from another server.... Archived from groups: comp>lang>php (more info?)
|
|
|
I have a question about what should be fairly simple to accomplish,
however it has not been for some strange reason. I have two servers
running apache and php. One is our public web server running linux
(port 80 is available through the firewall), the second is inside our
firewall running windows2000. The Windows 2000 server is has several
scripts written to extract data from our MS SQL server through an ODBC
connection and everything works great. My challenge has been
displaying data from the SQL server to our customers through the
internet via the Linux box. I thought including a page using
include("http://......") was going to do it, but I have not been
successful in getting it to work. Here are the three files I am
dealing with:
kld.php (on Linux Box)
<?
include("http://10.0.17.6/includes/MsSQL_db.php");
$data_local = include("http://10.0.17.6/get_data.php?userid=1021");
print_r ($data_local);
?>
get_data.php (on Win2000 Box)
<?
include("includes/MsSQL_db.php");
$data = array();
$userid = $_GET['userid'];
$data = $MsSQL->get_pending_list_by_userid($userid);
return $data;
?>
MsSQL_db.php (also on Win2000 box)
<?
include("constants.php");
class MsSQL_DB {
var $connection;
function MsSQL_DB(){
$this->connection =
odbc_connect(MsSQL_DSN,MsSQL_USERNAME,MsSQL_PASSWORD);
}
function get_pending_list_by_userid($userid){
$this->data_array = array();
$q = "SELECT OrderID, BeginTime, Company, Clinic, Item FROM
InSync_Master_View where Interpreterid = ".$userid." and status =
'pending'";
$result=odbc_exec($this->connection, $q) or die ("<pre>Query
Failure: $q </pre>");
while ($row = odbc_fetch_array($result)) {
$this->data_array[] .= $row['OrderID'].", ".$row['BeginTime'].", ".
$row['Company'].", ".$row['Clinic'].", ".$row['Item']."<br>";
}
return $this->data_array;
}
}
$MsSQL = new MsSQL_DB;
?>
My problem is that by the time the array that I started with in the
function call gets back to kld.php it is not a multidimensional array
any more, at this point when print_r($local_data) runs all I get is a
1. If I change "return" to echo on get_data.php it will print my array
on the first page but I would like to receive it back in an array in
kld.php so I can sort it and manipulate the data before printing it.
Any help on this would be greatly appreciated. >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Feb 04, 2008 Posts: 5
|
(Msg. 2) Posted: Mon Feb 04, 2008 11:06 am
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
| What about using something like AJAX to retrieve the data? I want to
have a table on the page that can be sorted without page reloads and
was looking into using AJAX to create that, maybe that is a good way
to get the data initially?
|
>> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Feb 04, 2008 Posts: 5
|
(Msg. 3) Posted: Mon Feb 04, 2008 12:03 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Feb 4, 12:35 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.org> wrote:
> breakaway9 wrote:
> > I have two servers running apache and php. One is our public web server
> > running linux [...] the second is inside our firewall running windows2000.
> > The Windows 2000 server is has several scripts written to extract data
> > from our MS SQL server through an ODBC connection and everything works
> > great. My challenge has been displaying data from the SQL server to our
> > customers through the internet via the Linux box.
>
> So, why don't you make a direct connection from the linux box to the MS SQL
> database via ODBC?
>
> --
> ----------------------------------
> Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> Hay una cosa tan inevitable como la muerte: la vida.- Charles Chaplin.
Ivan,
Initially that made the most sense, however I don't have $1,500 for
the ODBC driver. If it were not so expensive that would be my choice
as well... >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Feb 04, 2008 Posts: 5
|
(Msg. 4) Posted: Mon Feb 04, 2008 12:05 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Feb 4, 12:41 pm, Michael Fesser wrote:
> .oO(breakaway9)
>
> >What about using something like AJAX to retrieve the data? I want to
> >have a table on the page that can be sorted without page reloads and
> >was looking into using AJAX to create that, maybe that is a good way
> >to get the data initially?
>
> That's what you can achieve with SOAP or a simple serialize/unserialize,
> as described in my previous posting: The client (in this case your
> public web server) sends a HTTP request to the server (your internal
> machine), the server sends something back and the client interprets the
> data in a certain way.
>
> It's always more or less just that, when data is transfered over HTTP.
> Whether it's called AJAX, SOAP or whatever doesn't really matter - the
> main principle is always the same: request, response, interpretation.
> The only real difference is where these techniques are used. SOAP is
> often used in server-to-server communication, while AJAX plays its main
> role in browser-to-server communication.
>
> Micha
Awesome that makes sense. I will go read about it and try and figure
out what makes the most sense in the current environment.
Thanks for your help. >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Feb 04, 2008 Posts: 5
|
(Msg. 5) Posted: Mon Feb 04, 2008 2:59 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Feb 4, 2:38 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.org> wrote:
> breakaway9 wrote:
> >> So, why don't you make a direct connection from the linux box to the MS
> >> SQL database via ODBC?
>
> > Initially that made the most sense, however I don't have $1,500 for
> > the ODBC driver. If it were not so expensive that would be my choice
> > as well...
>
> Given that I can download this into my Debian box:
>
> http://packages.debian.org/etch/php5-odbc
>
> I do have to ask: $1500 for *what*?
>
> --
> ----------------------------------
> Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
>
> Now listening to: Chambao - Pokito a poko (2005) - [4] Camino interior
> (4:20) (96.333298%)
Well that is so that PHP can speak to your ODBC drivers, you still
have to purchase your drivers, which is where the cost comes in. That
is the package I use to access the data on the windows server, which
has the SQL Server Drivers built in. There is one free option,
something like "TLS" but you have to recompile quite a few
applications to get it to work which I am a bit uncomfortable doing on
our production web server. >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Dec 17, 2007 Posts: 886
|
(Msg. 6) Posted: Mon Feb 04, 2008 7:39 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
..oO(breakaway9)
>I have a question about what should be fairly simple to accomplish,
>however it has not been for some strange reason. I have two servers
>running apache and php. One is our public web server running linux
>(port 80 is available through the firewall), the second is inside our
>firewall running windows2000. The Windows 2000 server is has several
>scripts written to extract data from our MS SQL server through an ODBC
>connection and everything works great. My challenge has been
>displaying data from the SQL server to our customers through the
>internet via the Linux box. I thought including a page using
>include("http://......") was going to do it, but I have not been
>successful in getting it to work. Here are the three files I am
>dealing with:
>
>kld.php (on Linux Box)
>
><?
>include("http://10.0.17.6/includes/MsSQL_db.php");
>$data_local = include("http://10.0.17.6/get_data.php?userid=1021");
>print_r ($data_local);
>?>
>
>get_data.php (on Win2000 Box)
>[...]
>
>MsSQL_db.php (also on Win2000 box)
>[...]
>
>My problem is that by the time the array that I started with in the
>function call gets back to kld.php it is not a multidimensional array
>any more, at this point when print_r($local_data) runs all I get is a
>1. If I change "return" to echo on get_data.php it will print my array
>on the first page but I would like to receive it back in an array in
>kld.php so I can sort it and manipulate the data before printing it.
>Any help on this would be greatly appreciated.
You have to remember what happens if you include a file via HTTP. It is
like calling a webpage on another server (you can even append URL
parameters if necessary). The remote server will execute the script
(assuming the server is capable of running PHP) and return the output(!)
of that script to the caller. You won't get any variables or data
structures back, but an HTML string.
There are at least two options:
* The internal server could print the data in a serialized form.
The calling script would have to unserialize it, but can then perform
further actions on the data. This might require kinda hack with output
buffering to capture the returned data.
* Have a look at remote procedure calls (RPC) and webservices (SOAP).
Micha >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Dec 27, 2007 Posts: 146
|
(Msg. 7) Posted: Mon Feb 04, 2008 8:35 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
breakaway9 wrote:
> I have two servers running apache and php. One is our public web server
> running linux [...] the second is inside our firewall running windows2000.
> The Windows 2000 server is has several scripts written to extract data
> from our MS SQL server through an ODBC connection and everything works
> great. My challenge has been displaying data from the SQL server to our
> customers through the internet via the Linux box.
So, why don't you make a direct connection from the linux box to the MS SQL
database via ODBC?
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
Hay una cosa tan inevitable como la muerte: la vida.- Charles Chaplin. >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Dec 17, 2007 Posts: 886
|
(Msg. 8) Posted: Mon Feb 04, 2008 8:41 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
..oO(breakaway9)
>What about using something like AJAX to retrieve the data? I want to
>have a table on the page that can be sorted without page reloads and
>was looking into using AJAX to create that, maybe that is a good way
>to get the data initially?
That's what you can achieve with SOAP or a simple serialize/unserialize,
as described in my previous posting: The client (in this case your
public web server) sends a HTTP request to the server (your internal
machine), the server sends something back and the client interprets the
data in a certain way.
It's always more or less just that, when data is transfered over HTTP.
Whether it's called AJAX, SOAP or whatever doesn't really matter - the
main principle is always the same: request, response, interpretation.
The only real difference is where these techniques are used. SOAP is
often used in server-to-server communication, while AJAX plays its main
role in browser-to-server communication.
Micha >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
External

Since: Dec 27, 2007 Posts: 146
|
(Msg. 9) Posted: Mon Feb 04, 2008 10:38 pm
Post subject: Re: Data from another server.... [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
breakaway9 wrote:
>> So, why don't you make a direct connection from the linux box to the MS
>> SQL database via ODBC?
>
> Initially that made the most sense, however I don't have $1,500 for
> the ODBC driver. If it were not so expensive that would be my choice
> as well...
Given that I can download this into my Debian box:
http://packages.debian.org/etch/php5-odbc
I do have to ask: $1500 for *what*?
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
Now listening to: Chambao - Pokito a poko (2005) - [4] Camino interior
(4:20) (96.333298%) >> Stay informed about: Data from another server.... |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can 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
|
|
|
|
 |
|
|