Need advanced help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
303tech
Forum Commoner
Posts: 31
Joined: Sun Mar 11, 2007 3:25 pm

Need advanced help.

Post by 303tech »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


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.

Code: Select all

<?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

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply