Im trying to create a gui that will allow the user to update/configure the server’s default ftp location. There is a configuration table that contains paths for the ftp site as well as usernames and passwords.
In the following code i attempt to read out of the database, and use the old username as a way to make a regular expression match. once ive found the match, i substitute the old username for the new one. This is to update the path names correctly. However im not successful in storing the value of the old username. This method works fine when the hash iterates through the username BEFORE the paths, but if the config table was loaded ‘upsidedown’ it doesnt work at all, i get a null value for the old username.
here is the code:
[QUOTE]
function make_config($site, $username, $password) {
$sql = “SELECT cname, cvalue FROM config “;
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$configHash = array(“$row[cname]” => “$row[cvalue]”);
echo “$configHash[ftp_user] here<br>n”;
if($configHash[ftp_user]) {
$reg_match = $configHash[ftp_user];
}
foreach($configHash as $key => $val) {
if($key == “ftp_user”) {
$val = $username;
}
if($key == “ftp_pass”) {
$val = $password;
}
if($key == “ftp_host_id”) {
$val = $site;
}
if($key == “host_location”) {
$val = $site;
}
$home = preg_match(‘/^/home//’, $val);
if(($home) && ($key != “ftp_log_file_send”) && ($key != “ftp_log_file_recon”)) {
print(“Here is reg_match: $reg_match<br>n”);
print(“Here is val before parse: $val<br>n”);
$val = str_replace($reg_match, $username, $val);
print(“And here is val after parse: $val<br>n”);
}
//config_update($key, $val);
}
}
}
Any help would be appreciated, im new to PHP and i THOUGHT i had the syntax nailed down — but apparently this problem is a bit elusive.