PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun May 31, 2020 12:55 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Need advanced help.
PostPosted: Thu Jun 28, 2007 1:52 pm 
Offline
Forum Commoner

Joined: Sun Mar 11, 2007 3:25 pm
Posts: 31
feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: to learn how to do it too. 
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Heres what I have: 
  8.  
  9.  
  10.  
  11. Computer A: File Server which reports information from INI file. 
  12.  
  13.  
  14.  
  15. Computer B: Web Server which collects information from INI to store in SQL 
  16.  
  17.  
  18.  
  19. GOAL: Computer A wants to send information of the ini and PUBLIC IP address everytime the related application loads, to Computer B's SQL server. The admin backend would have access to this information. 
  20.  
  21.  
  22.  
  23. The script i have. 
Syntax: [ Download ] [ Hide ]
<?php

//connection

include ("connect.php");  



//PARSE INI FILE.

$ini = parse_ini_file('prog.ini');



//REMOVE APOSTROPHES FROM NAME.  

$un=$ini['UNITNAME'];



$replace=str_replace("'","",$un);

echo $replace;



$ip=$_SERVER['REMOTE_ADDR'];

echo $ip;



//DEFINE KEYS

$sec1=$ini['SEC1'];

echo $sec1;



$sec2=$ini['SEC2'];

echo $sec2;



$sec3 = $ini['SEC3'];



$sec4 = $ini['SEC4'];



$sec5=$ini['SEC5'];



$sec6=$ini['SEC6'];



//IF STATEMENT

$rows=mysql_query("SELECT * FROM customer WHERE sec1='$sec1'");

$num_rows= mysql_num_rows($rows);



if ($num_rows>=1)

{

echo "There is already a unit assigned.";

mysql_query("UPDATE customer SET unitname='$replace2' WHERE sec1='$sec1'");

echo "UPDATED CUSTOMER";

exit;

}

echo "No rows found, so i will insert";

//INSERT VALUES

$insert="INSERT INTO customer (unitname,sec1, sec2, sec3, sec4, sec5, sec6,ip,c1) VALUES ('$un','$sec1','$sec2','$sec3','$sec4','$sec5','$sec6','$ip','$c1')";

mysql_query($insert);



?>


The problem i have is....
Either i can put this insert.php file on the Computer A and when it runs it will look on the c:\targetdir\ - (and have to install WAMP or php/apache) which works okay, but when i try to get the local IP its the loopback 127.0.0.1 addy. With this I am able to do everything i need except get the correct ip. The downfall is that i have to install WAMP or php/apache.

OR

I can ideally have the php page run remotely from Computer B where when the related application loads, it would either:
A. Somehow reach into Computer A on the C:\targetdir\ and parse the ini remotely. (please let me know if theres a way)
B. Upload the ini somewhere on the webserver daily with scheduled task, but then the php insert file would have to tell the webserver an ID to look up (which i think i would have to assign at the beginning of each Computer A (There will be hundreds of Computer A locations) This would be a hassle....

Thanks in advance for any ideas.

Nick


feyd | Please use
Syntax: [ Download ] [ Hide ]
,
[syntax=php]and
Syntax: [ Download ] [ Hide ]
  1. tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: to learn how to do it too. 


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 11 guests


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group