303tech Posted June 28, 2007 Share Posted June 28, 2007 Heres what I have: Computer A: File Server which reports information from INI file. Computer B: Web Server which collects information from INI to store in SQL 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. The script i have. <?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 ('$replace','$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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.